style: format code with black and add trailing commas

This commit is contained in:
Paul Gauthier (aider) 2024-11-27 06:23:25 -08:00
parent 5c73ab26c0
commit 48ea13e130

View file

@ -385,92 +385,117 @@ class Greeter {
} }
} }
""", """,
"Greeter" # Key symbol to check "Greeter", # Key symbol to check
), ),
"c": ( "c": (
"test.c", "test.c",
'#include <stdio.h>\n\nint main() {\n printf("Hello, World!\\n");\n return 0;\n}\n', (
"main" # Key symbol to check '#include <stdio.h>\n\nint main() {\n printf("Hello, World!\\n");\n '
" return 0;\n}\n"
),
"main", # Key symbol to check
), ),
"csharp": ( "csharp": (
"test.cs", "test.cs",
'using System;\n\nclass Program {\n static void Main() {\n Console.WriteLine("Hello, World!");\n }\n}\n', (
"Program" # Key symbol to check "using System;\n\nclass Program {\n static void Main() {\n "
' Console.WriteLine("Hello, World!");\n }\n}\n'
),
"Program", # Key symbol to check
), ),
"cpp": ( "cpp": (
"test.cpp", "test.cpp",
'#include <iostream>\n\nint main() {\n std::cout << "Hello, World!" << std::endl;\n return 0;\n}\n', (
"main" # Key symbol to check '#include <iostream>\n\nint main() {\n std::cout << "Hello, World!" <<'
" std::endl;\n return 0;\n}\n"
),
"main", # Key symbol to check
), ),
"elisp": ( "elisp": (
"test.el", "test.el",
'(defun greet (name)\n (message "Hello, %s!" name))\n', '(defun greet (name)\n (message "Hello, %s!" name))\n',
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"elixir": ( "elixir": (
"test.ex", "test.ex",
'defmodule Greeter do\n def hello(name) do\n IO.puts("Hello, #{name}!")\n end\nend\n', (
"Greeter" # Key symbol to check 'defmodule Greeter do\n def hello(name) do\n IO.puts("Hello, #{name}!")\n '
" end\nend\n"
),
"Greeter", # Key symbol to check
), ),
"elm": ( "elm": (
"test.elm", "test.elm",
'module Main exposing (main)\n\nimport Html exposing (text)\n\nmain =\n text "Hello, World!"\n', (
"Main" # Key symbol to check "module Main exposing (main)\n\nimport Html exposing (text)\n\nmain =\n text"
' "Hello, World!"\n'
),
"Main", # Key symbol to check
), ),
"go": ( "go": (
"test.go", "test.go",
'package main\n\nimport "fmt"\n\nfunc main() {\n fmt.Println("Hello, World!")\n}\n', (
"main" # Key symbol to check 'package main\n\nimport "fmt"\n\nfunc main() {\n fmt.Println("Hello,'
' World!")\n}\n'
),
"main", # Key symbol to check
), ),
"java": ( "java": (
"Test.java", "Test.java",
'public class Test {\n public static void main(String[] args) {\n System.out.println("Hello, World!");\n }\n}\n', (
"Test" # Key symbol to check "public class Test {\n public static void main(String[] args) {\n "
' System.out.println("Hello, World!");\n }\n}\n'
),
"Test", # Key symbol to check
), ),
"javascript": ( "javascript": (
"test.js", "test.js",
"function greet(name) {\n console.log(`Hello, ${name}!`);\n}\n", "function greet(name) {\n console.log(`Hello, ${name}!`);\n}\n",
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"ocaml": ( "ocaml": (
"test.ml", "test.ml",
'let greet name =\n Printf.printf "Hello, %s!\\n" name\n', 'let greet name =\n Printf.printf "Hello, %s!\\n" name\n',
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"php": ( "php": (
"test.php", "test.php",
'<?php\nfunction greet($name) {\n echo "Hello, $name!";\n}\n?>\n', '<?php\nfunction greet($name) {\n echo "Hello, $name!";\n}\n?>\n',
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"python": ( "python": (
"test.py", "test.py",
'def greet(name):\n print(f"Hello, {name}!")\n', 'def greet(name):\n print(f"Hello, {name}!")\n',
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"ql": ( "ql": (
"test.ql", "test.ql",
'predicate greet(string name) {\n name = "World"\n}\n', 'predicate greet(string name) {\n name = "World"\n}\n',
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"ruby": ( "ruby": (
"test.rb", "test.rb",
'def greet(name)\n puts "Hello, #{name}!"\nend\n', 'def greet(name)\n puts "Hello, #{name}!"\nend\n',
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"rust": ( "rust": (
"test.rs", "test.rs",
'fn main() {\n println!("Hello, World!");\n}\n', 'fn main() {\n println!("Hello, World!");\n}\n',
"main" # Key symbol to check "main", # Key symbol to check
), ),
"typescript": ( "typescript": (
"test.ts", "test.ts",
"function greet(name: string): void {\n console.log(`Hello, ${name}!`);\n}\n", "function greet(name: string): void {\n console.log(`Hello, ${name}!`);\n}\n",
"greet" # Key symbol to check "greet", # Key symbol to check
), ),
"tsx": ( "tsx": (
"test.tsx", "test.tsx",
"import React from 'react';\n\nconst Greeting: React.FC<{ name: string }> = ({ name }) => {\n return <h1>Hello, {name}!</h1>;\n};\n\nexport default Greeting;\n", (
"Greeting" # Key symbol to check "import React from 'react';\n\nconst Greeting: React.FC<{ name: string }> = ({"
" name }) => {\n return <h1>Hello, {name}!</h1>;\n};\n\nexport default"
" Greeting;\n"
),
"Greeting", # Key symbol to check
), ),
} }
@ -481,13 +506,19 @@ class Greeter {
io = InputOutput() io = InputOutput()
repo_map = RepoMap(main_model=self.GPT35, root=temp_dir, io=io) repo_map = RepoMap(main_model=self.GPT35, root=temp_dir, io=io)
other_files = [os.path.join(temp_dir, filename) for filename, _, _ in language_files.values()] other_files = [
os.path.join(temp_dir, filename) for filename, _, _ in language_files.values()
]
result = repo_map.get_repo_map([], other_files) result = repo_map.get_repo_map([], other_files)
# Check if the result contains all the expected files and symbols # Check if the result contains all the expected files and symbols
for lang, (filename, _, key_symbol) in language_files.items(): for lang, (filename, _, key_symbol) in language_files.items():
self.assertIn(filename, result, f"File for language {lang} not found in repo map") self.assertIn(filename, result, f"File for language {lang} not found in repo map")
self.assertIn(key_symbol, result, f"Key symbol '{key_symbol}' for language {lang} not found in repo map") self.assertIn(
key_symbol,
result,
f"Key symbol '{key_symbol}' for language {lang} not found in repo map",
)
# close the open cache files, so Windows won't error # close the open cache files, so Windows won't error
del repo_map del repo_map