From 23f84e3a46aceb5a3bacdbd82f70e1b771e60966 Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Wed, 29 Jan 2025 11:00:27 -0800 Subject: [PATCH 01/12] add ruff rules --- ruff.toml | 17 ++++++++++++++++- .../sdk/core/detached_symbols/function_call.py | 2 +- src/codegen/sdk/core/import_resolution.py | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ruff.toml b/ruff.toml index 64eb33912..338b939e4 100644 --- a/ruff.toml +++ b/ruff.toml @@ -6,7 +6,20 @@ exclude = [ ] unsafe-fixes = true [lint] -select = ["F", "E", "W", "I", "UP", "D", "RUF", "DTZ", "TC", "EM", "TRY400"] +select = [ + "F", + "E", + "W", + "I", + "UP", + "D", + "YTT", + "RUF", + "DTZ", + "TC", + "EM", + "TRY400", +] ignore = [ "D100", "D101", @@ -216,3 +229,5 @@ extend-generics = [ ] [lint.isort] known-first-party = ["codegen"] +[format] +docstring-code-format = true diff --git a/src/codegen/sdk/core/detached_symbols/function_call.py b/src/codegen/sdk/core/detached_symbols/function_call.py index 7699343e9..cb8d1ba5d 100644 --- a/src/codegen/sdk/core/detached_symbols/function_call.py +++ b/src/codegen/sdk/core/detached_symbols/function_call.py @@ -42,7 +42,7 @@ class FunctionCall(Expression[Parent], HasName, Resolvable, Generic[Parent]): """Abstract representation of a function invocation, e.g. in Python: ``` def f(): - g() # FunctionCall + g() # FunctionCall ``` """ diff --git a/src/codegen/sdk/core/import_resolution.py b/src/codegen/sdk/core/import_resolution.py index 432ec2ab5..1c35dcf2c 100644 --- a/src/codegen/sdk/core/import_resolution.py +++ b/src/codegen/sdk/core/import_resolution.py @@ -403,6 +403,7 @@ def is_dynamic(self) -> bool: def my_function(): import foo # Dynamic - only imported when function runs + if condition: from bar import baz # Dynamic - only imported if condition is True From ea83947ba80c5cfc655a9cdb8f9279c541b66c37 Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Wed, 29 Jan 2025 11:01:15 -0800 Subject: [PATCH 02/12] update tests --- tests/conftest.py | 12 +++-- .../git/clients/test_github_client_factory.py | 4 +- .../test_remote_repo_operator.py | 6 +-- tests/integration/codegen/test_imports.py | 4 +- tests/integration/codemod/test_diffs.py | 2 +- .../codemod/codebase_comparison_utils.py | 2 +- tests/shared/codemod/commands.py | 14 ++--- .../shared/codemod/verified_codemod_utils.py | 2 +- tests/shared/mocks/mock_ai_helper.py | 2 +- tests/shared/skills/decorators.py | 2 +- tests/shared/skills/skill.py | 2 +- tests/shared/skills/skill_implementation.py | 4 +- tests/shared/skills/utils.py | 4 +- tests/shared/utils/recursion.py | 2 +- tests/unit/codegen/cli/conftest.py | 5 +- tests/unit/codegen/cli/test_reset.py | 12 ++--- .../git/clients/test_git_repo_client.py | 6 +-- tests/unit/codegen/git/schemas/test_github.py | 2 +- tests/unit/codegen/gscli/test_cli.py | 2 +- .../codegen/runner/sandbox/test_executor.py | 16 +++--- .../codegen/runner/sandbox/test_runner.py | 10 ++-- .../codegen/runner/utils/test_branch_name.py | 4 +- .../benchmark/codebase/test_codebase_reset.py | 6 +-- .../test_codemod_writer_decorators.py | 2 +- .../codebase_graph/test_codebase_reset.py | 28 +++++----- .../test_symbol_parent_statement.py | 8 +-- .../sdk/codebase/flagging/test_code_flag.py | 2 +- .../sdk/codebase/flagging/test_group_all.py | 2 +- .../test_transaction_mangager_checks.py | 8 +-- tests/unit/codegen/sdk/conftest.py | 2 +- .../codebase/test_codebase_raise_error.py | 2 +- .../sdk/python/codebase/test_control_flow.py | 16 +++--- .../code_block/test_code_block_indent.py | 14 ++--- .../code_block/test_code_block_insert.py | 18 +++---- .../code_block/test_code_block_remove.py | 10 ++-- .../code_block/test_code_block_unwrap.py | 8 +-- .../code_block/test_code_block_wrap.py | 4 +- .../test_function_calls_from_symbol.py | 18 +++---- .../expressions/test_binary_expression.py | 14 ++--- .../test_binary_reduce_condition.py | 10 ++-- .../sdk/python/expressions/test_boolean.py | 2 +- .../sdk/python/expressions/test_number.py | 2 +- .../sdk/python/expressions/test_type.py | 8 +-- .../python/function/test_function_async.py | 4 +- .../import_resolution/test_is_dynamic.py | 22 ++++---- .../test_if_block_reduce_block.py | 26 ++++----- .../test_with_statement_properties.py | 10 ++-- .../code_block/test_code_block_indent.py | 14 ++--- .../code_block/test_code_block_unwrap.py | 8 +-- .../code_block/test_code_block_wrap.py | 2 +- .../typescript/export/test_export_aliased.py | 6 +-- .../export/test_export_export_statement.py | 22 ++++---- .../typescript/export/test_external_export.py | 12 ++--- .../export/test_get_reexported_exports.py | 6 +-- .../test_ternary_reduce_condition.py | 18 +++---- .../expressions/test_binary_expression.py | 4 +- .../test_binary_reduce_condition.py | 14 ++--- .../typescript/expressions/test_boolean.py | 2 +- .../sdk/typescript/expressions/test_dict.py | 52 +++++++++--------- .../typescript/expressions/test_expression.py | 6 +-- .../sdk/typescript/expressions/test_number.py | 2 +- .../file/test_file_export_statements.py | 54 +++++++++---------- .../function/test_function_async.py | 6 +-- .../test_function_calls_from_symbol.py | 20 +++---- .../test_function_parameter_to_interface.py | 8 +-- .../import_resolution/test_is_dynamic.py | 22 ++++---- .../typescript/react/test_interface_props.py | 26 ++++----- .../typescript/react/test_ts_declassify.py | 2 +- .../test_if_block_reduce_block.py | 22 ++++---- .../compilation/test_codeblock_validation.py | 4 +- .../compilation/test_function_compilation.py | 16 +++--- .../compilation/test_function_construction.py | 8 +-- .../shared/compilation/test_string_to_code.py | 18 +++---- tests/unit/codemods/test_codemod.py | 4 +- .../unit/skills/implementations/ai_skills.py | 8 +-- .../skills/implementations/asyncify_skills.py | 4 +- .../implementations/code_block_skills.py | 14 ++--- .../skills/implementations/comment_skills.py | 2 +- .../implementations/decorator_skills.py | 8 +-- .../skills/implementations/eval_skills.py | 42 +++++++-------- .../skills/implementations/example_skills.py | 32 +++++------ .../skills/implementations/export_skills.py | 2 +- .../implementations/expressions/dict.py | 2 +- .../implementations/expressions/list.py | 6 +-- .../implementations/expressions/type.py | 8 +-- .../feature_flag_deletion_skill.py | 4 +- .../skills/implementations/function_skills.py | 4 +- .../implementations/global_var_skills.py | 4 +- .../graph_viz/graph_viz_app_imports.py | 2 +- .../graph_viz/graph_viz_call_graph.py | 12 ++--- .../graph_viz/graph_viz_dead_code.py | 2 +- .../graph_viz/graph_viz_dir_tree.py | 2 +- .../graph_viz/graph_viz_foreign_key.py | 2 +- .../code-quality-metrics/import-loops.py | 2 +- .../code-quality-metrics/large-files.py | 2 +- .../missing-documentation.py | 2 +- .../code-quality-metrics/unnamed-kwargs.py | 2 +- .../untyped-attributes.py | 2 +- .../untyped-parameters.py | 2 +- .../untyped-return-types.py | 2 +- .../implementations/guides/codebase-ai.py | 8 +-- .../guides/complex-renaming.py | 14 ++--- .../guides/creating-documentation.py | 10 ++-- .../guides/deleting-dead-code.py | 14 ++--- .../guides/increase-type-coverage.py | 20 +++---- .../guides/manipulating-collections.py | 16 +++--- .../guides/organize-your-codebase.py | 16 +++--- .../implementations/if_statement_skills.py | 4 +- .../implementations/move_symbols_skills.py | 4 +- .../type_inheritance_skills.py | 13 ++--- tests/unit/skills/test_skills.py | 2 +- 111 files changed, 522 insertions(+), 516 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index df179d306..65680b60f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,7 +17,7 @@ def find_dirs_to_ignore(start_dir, prefix): return dirs_to_ignore -def pytest_addoption(parser): +def pytest_addoption(parser) -> None: parser.addoption( "--size", action="append", @@ -68,7 +68,7 @@ def pytest_addoption(parser): # content of conftest.py -def pytest_configure(config): +def pytest_configure(config) -> None: worker_id = os.environ.get("PYTEST_XDIST_WORKER") if worker_id is not None: os.makedirs("build/logs", exist_ok=True) @@ -101,7 +101,7 @@ def pytest_runtest_makereport(item, call): @pytest.fixture(autouse=True) -def skip_lfs_tests(request): +def skip_lfs_tests(request) -> None: """Skip tests that depend on git LFS files if they haven't been pulled""" # Lets not run if we are in CI if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true": @@ -111,7 +111,11 @@ def skip_lfs_tests(request): test_path = Path(request.module.__file__) # Only run for integration tests - if not str(test_path).startswith(str(Path.cwd() / "tests" / "integration")): + try: + cwd = Path.cwd() + except FileNotFoundError: + return + if not str(test_path).startswith(str(cwd / "tests" / "integration")): return try: diff --git a/tests/integration/codegen/git/clients/test_github_client_factory.py b/tests/integration/codegen/git/clients/test_github_client_factory.py index 668faae0e..00e81d8cf 100644 --- a/tests/integration/codegen/git/clients/test_github_client_factory.py +++ b/tests/integration/codegen/git/clients/test_github_client_factory.py @@ -2,7 +2,7 @@ from codegen.git.schemas.github import GithubType -def test_github_client_factory_create_from_token_no_token(): +def test_github_client_factory_create_from_token_no_token() -> None: github_client = GithubClientFactory.create_from_token(github_type=GithubType.Github) assert github_client.base_url == "https://api.github.com" repo = github_client.read_client.get_repo("python-lsp/python-lsp-server") @@ -10,7 +10,7 @@ def test_github_client_factory_create_from_token_no_token(): assert repo.name == "python-lsp-server" -def test_github_client_factory_create_from_repo(repo_config): +def test_github_client_factory_create_from_repo(repo_config) -> None: github_client = GithubClientFactory.create_from_repo(repo_config=repo_config, github_type=GithubType.Github) repo = github_client.read_client.get_repo("codegen-sh/Kevin-s-Adventure-Game") assert repo.full_name == "codegen-sh/Kevin-s-Adventure-Game" diff --git a/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py b/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py index 99604e0d4..f3f2ee97a 100644 --- a/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py +++ b/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py @@ -18,7 +18,7 @@ def op(repo_config, request, tmpdir): @pytest.mark.parametrize("op", shallow_options, ids=lambda x: f"shallow={x}", indirect=True) @patch("codegen.git.clients.github_client.Github") -def test_checkout_branch(mock_git_client, op: RemoteRepoOperator): +def test_checkout_branch(mock_git_client, op: RemoteRepoOperator) -> None: mock_git_client.return_value = Github("test_token", "https://api.github.com") op.pull_repo() op.checkout_commit(op.head_commit) @@ -40,7 +40,7 @@ def test_checkout_branch(mock_git_client, op: RemoteRepoOperator): @pytest.mark.parametrize("op", [True], ids=lambda x: f"shallow={x}", indirect=True) @patch("codegen.git.clients.github_client.Github") -def test_checkout_branch_local_already_checked_out(mock_git_client, op: RemoteRepoOperator): +def test_checkout_branch_local_already_checked_out(mock_git_client, op: RemoteRepoOperator) -> None: mock_git_client.return_value = Github("test_token", "https://api.github.com") op.checkout_commit(op.head_commit) @@ -60,7 +60,7 @@ def test_checkout_branch_local_already_checked_out(mock_git_client, op: RemoteRe @pytest.mark.parametrize("op", [True], ids=lambda x: f"shallow={x}", indirect=True) @patch("codegen.git.clients.github_client.Github") -def test_checkout_branch_remote_already_checked_out_resets_branch(mock_git_client, op: RemoteRepoOperator): +def test_checkout_branch_remote_already_checked_out_resets_branch(mock_git_client, op: RemoteRepoOperator) -> None: mock_git_client.return_value = Github("test_token", "https://api.github.com") original_commit_head = op.head_commit diff --git a/tests/integration/codegen/test_imports.py b/tests/integration/codegen/test_imports.py index e2af00f64..7dc889965 100644 --- a/tests/integration/codegen/test_imports.py +++ b/tests/integration/codegen/test_imports.py @@ -2,10 +2,10 @@ from codegen import Codebase -def test_codegen_imports(): +def test_codegen_imports() -> None: # Test decorated function @codegen.function(name="sample_codemod") - def run(codebase): + def run(codebase) -> None: pass # Test class diff --git a/tests/integration/codemod/test_diffs.py b/tests/integration/codemod/test_diffs.py index 5745caef2..d0f59443b 100644 --- a/tests/integration/codemod/test_diffs.py +++ b/tests/integration/codemod/test_diffs.py @@ -21,7 +21,7 @@ def test_codemods_diffs(_codebase: Codebase, expected: Path) -> None: verify_diffs(_codebase) -def verify_diffs(_codebase): +def verify_diffs(_codebase) -> None: modified = gather_modified_files(_codebase) diffs = [DiffLite.from_git_diff(diff) for diff in _codebase.get_diffs()] _codebase.G.apply_diffs(diffs) diff --git a/tests/shared/codemod/codebase_comparison_utils.py b/tests/shared/codemod/codebase_comparison_utils.py index 85659d307..e2f8781f1 100644 --- a/tests/shared/codemod/codebase_comparison_utils.py +++ b/tests/shared/codemod/codebase_comparison_utils.py @@ -149,7 +149,7 @@ def capture_single_file_stats(files_dir: Path, files, expected_dir: Path, extens return diff -def capture_modified_file_stats(left_lines: list[str], right_lines: list[str], diff_stats: dict): +def capture_modified_file_stats(left_lines: list[str], right_lines: list[str], diff_stats: dict) -> None: """Captures stats on the differences between two complementary files, a file that exists in both the expected and modified codebases. """ diff --git a/tests/shared/codemod/commands.py b/tests/shared/codemod/commands.py index b7d2984dc..74bacc08c 100644 --- a/tests/shared/codemod/commands.py +++ b/tests/shared/codemod/commands.py @@ -23,24 +23,24 @@ def codemod() -> None: @codemod.command() @click.option("--extra-repos", is_flag=True) -def generate_cases(extra_repos: bool = False): +def generate_cases(extra_repos: bool = False) -> None: """Generate cases for codemod tests. Very slow""" repos = find_repos(extra_repos=extra_repos) for codemod in find_codemods(): - for repo_name, repo in repos.items(): + for repo_name in repos.keys(): (codemod.test_dir / f"test_{repo_name}").mkdir(parents=True, exist_ok=True) _generate_diffs(extra_repos=extra_repos) _clean_diffs(aggressive=True) -def _generate_diffs(extra_repos: bool = False): +def _generate_diffs(extra_repos: bool = False) -> None: """Generate diffs for codemod tests""" os.system(f"pytest tests/integration/codemod/test_codemods.py::test_codemods_cloned_repos --size small --extra-repos={str(extra_repos).lower()} -n auto --snapshot-update") os.system(f"pytest tests/integration/codemod/test_codemods.py::test_codemods_cloned_repos --size large --extra-repos={str(extra_repos).lower()} -n auto --snapshot-update") @codemod.command() -def generate_diffs(): +def generate_diffs() -> None: """Generate diffs for codemod tests""" _generate_diffs() _clean_diffs() @@ -67,7 +67,7 @@ def gather_repos_per_codemod() -> dict[str, dict[tuple[Size, bool], list[ClonedR MAX_CASES = {Size.Small: 1, Size.Large: 1} -def _clean_diffs(aggressive: bool = False): +def _clean_diffs(aggressive: bool = False) -> None: repos = {**find_repos(extra_repos=True), **find_repos(extra_repos=False)} for test_case in find_codemod_test_cases(repos=repos): @@ -93,7 +93,7 @@ def _clean_diffs(aggressive: bool = False): @codemod.command() @click.option("--aggressive", is_flag=True) -def clean_diffs(aggressive: bool = False): +def clean_diffs(aggressive: bool = False) -> None: _clean_diffs(aggressive) @@ -204,7 +204,7 @@ def _fetch_and_store_codemod(repo_id: str, url: str, cli_api_key: str) -> tuple[ @codemod.command() @click.option("--cli-api-key", required=True, help="API key for authentication") -def fetch_verified_codemods(cli_api_key: str): +def fetch_verified_codemods(cli_api_key: str) -> None: """Fetch codemods for all repos in REPO_ID_TO_URL and save to JSON files.""" VERIFIED_CODEMOD_DATA_DIR.mkdir(parents=True, exist_ok=True) repos_to_commits: dict[str, list[dict]] = {} diff --git a/tests/shared/codemod/verified_codemod_utils.py b/tests/shared/codemod/verified_codemod_utils.py index af5984158..0fb5ea40c 100644 --- a/tests/shared/codemod/verified_codemod_utils.py +++ b/tests/shared/codemod/verified_codemod_utils.py @@ -83,7 +83,7 @@ def anonymized_name(self) -> str: class CodemodAPI: - def __init__(self, api_key: str | None = None, modal_prefix: str = "https://codegen-sh"): + def __init__(self, api_key: str | None = None, modal_prefix: str = "https://codegen-sh") -> None: self.api_key = api_key self.modal_prefix = modal_prefix self.get_codemods_url = f"{self.modal_prefix}--{GET_CODEMODS_URL_SUFFIX}" diff --git a/tests/shared/mocks/mock_ai_helper.py b/tests/shared/mocks/mock_ai_helper.py index b163cfeb3..203d977b9 100644 --- a/tests/shared/mocks/mock_ai_helper.py +++ b/tests/shared/mocks/mock_ai_helper.py @@ -31,5 +31,5 @@ def llm_query_functions_with_retry(self, model: str, messages: list, functions: def llm_query_functions(self, model: str, messages: list, functions: list[dict], max_tokens: int | None = None) -> None: pass - def llm_response_to_json(response) -> str: + def llm_response_to_json(self) -> str: pass diff --git a/tests/shared/skills/decorators.py b/tests/shared/skills/decorators.py index c6acec556..4b1179e3f 100644 --- a/tests/shared/skills/decorators.py +++ b/tests/shared/skills/decorators.py @@ -77,7 +77,7 @@ def properly_named_function(name: str, language: ProgrammingLanguage): return False -def skill_func_name_error(name: str, language: ProgrammingLanguage): +def skill_func_name_error(name: str, language: ProgrammingLanguage) -> str: if language == ProgrammingLanguage.PYTHON: return f"Function name must be 'skill_func', 'python_skill_func' or 'execute' for Python skills. Got {name}." elif language == ProgrammingLanguage.TYPESCRIPT: diff --git a/tests/shared/skills/skill.py b/tests/shared/skills/skill.py index 17b695faa..06525d4a7 100644 --- a/tests/shared/skills/skill.py +++ b/tests/shared/skills/skill.py @@ -29,7 +29,7 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: ... def typescript_skill_func(codebase: TSCodebaseType) -> callable: ... @staticmethod - def skill_func(codebase: CodebaseType): ... + def skill_func(codebase: CodebaseType) -> None: ... def execute(self, codebase: Codebase) -> None: ... diff --git a/tests/shared/skills/skill_implementation.py b/tests/shared/skills/skill_implementation.py index dc83a7049..c2d3c2d79 100644 --- a/tests/shared/skills/skill_implementation.py +++ b/tests/shared/skills/skill_implementation.py @@ -37,7 +37,7 @@ def __init__( si_id: int | None = None, from_app: bool = False, external: bool = False, - ): + ) -> None: self.name = name or skill_func.__name__ self.language = language self.test_cases = [] if skip_test else test_cases @@ -122,6 +122,6 @@ def function_body(self) -> str: def __call__(self, codebase: CodebaseType): self._skill_func(codebase) - def __str__(self): + def __str__(self) -> str: source = inspect.getsource(self._skill_func) return textwrap.dedent(source).strip() diff --git a/tests/shared/skills/utils.py b/tests/shared/skills/utils.py index 342d7d061..f206e43f4 100644 --- a/tests/shared/skills/utils.py +++ b/tests/shared/skills/utils.py @@ -17,7 +17,7 @@ CODEMODS_PATH: Path = REPO_ROOT_PATH / "src" / "codemods" / "canonical" -def import_skills_from(path: Path, module_prefix: str): +def import_skills_from(path: Path, module_prefix: str) -> None: for file in path.rglob("*.py"): relative_path = file.relative_to(path) if "evaluation" in relative_path.parts or "__init__" in file.name: @@ -26,7 +26,7 @@ def import_skills_from(path: Path, module_prefix: str): importlib.import_module(module) -def import_all_skills(): +def import_all_skills() -> None: import_skills_from(SKILLS_PATH, "tests.unit.skills.implementations") import_skills_from(CODEMODS_PATH, "codemods.canonical") diff --git a/tests/shared/utils/recursion.py b/tests/shared/utils/recursion.py index c816a4fab..2c5e4fbae 100644 --- a/tests/shared/utils/recursion.py +++ b/tests/shared/utils/recursion.py @@ -5,7 +5,7 @@ logger = logging.getLogger(__name__) -def set_recursion_limit(): +def set_recursion_limit() -> None: sys.setrecursionlimit(10**9) if sys.platform == "linux": logger.info(f"Setting stack limit to {resource.RLIM_INFINITY}") diff --git a/tests/unit/codegen/cli/conftest.py b/tests/unit/codegen/cli/conftest.py index 3263638ca..2d6421397 100644 --- a/tests/unit/codegen/cli/conftest.py +++ b/tests/unit/codegen/cli/conftest.py @@ -32,4 +32,7 @@ def initialized_repo(sample_repository: Path, runner: CliRunner): subprocess.run(["git", "add", "."], cwd=sample_repository, check=True) subprocess.run(["git", "commit", "-m", "Initialize codegen"], cwd=sample_repository, check=True) yield sample_repository - shutil.rmtree(sample_repository) + try: + shutil.rmtree(sample_repository) + except FileNotFoundError: + pass diff --git a/tests/unit/codegen/cli/test_reset.py b/tests/unit/codegen/cli/test_reset.py index cbbbb19fd..ae0c235e5 100644 --- a/tests/unit/codegen/cli/test_reset.py +++ b/tests/unit/codegen/cli/test_reset.py @@ -47,7 +47,7 @@ def committed_repo(initialized_repo: Path, committed_state: dict[str, str]) -> P return initialized_repo -def setup_repo_state(repo_path: Path, state: dict[str, str]): +def setup_repo_state(repo_path: Path, state: dict[str, str]) -> None: """Helper to set up files in the repo""" for filepath, content in state.items(): file_path = repo_path / filepath @@ -93,7 +93,7 @@ def get_git_status(repo_path: Path) -> tuple[set[str], set[str], set[str]]: def verify_git_state( repo_path: Path, expected_staged: set[str] | None = None, expected_modified: set[str] | None = None, expected_untracked: set[str] | None = None, rename_pairs: list[tuple[str, str]] | None = None -): +) -> None: """Verify git status matches expected state""" if rename_pairs is not None: for old_path, new_path in rename_pairs: @@ -114,7 +114,7 @@ def verify_git_state( assert untracked == expected_untracked, f"Untracked files mismatch.\nExpected: {expected_untracked}\nActual: {untracked}" -def verify_repo_state(repo_path: Path, expected_content: dict[str, str | None]): +def verify_repo_state(repo_path: Path, expected_content: dict[str, str | None]) -> None: """Verify file contents in repo""" for path, content in expected_content.items(): file_path = repo_path / path @@ -265,7 +265,7 @@ def create_test_case( ), ], ) -def test_reset(committed_repo: Path, committed_state: dict[str, str], test_case: ResetTestCase, runner: CliRunner): +def test_reset(committed_repo: Path, committed_state: dict[str, str], test_case: ResetTestCase, runner: CliRunner) -> None: """Test reset command with various scenarios""" # Get test case from factory function if needed if callable(test_case): @@ -299,7 +299,7 @@ def test_reset(committed_repo: Path, committed_state: dict[str, str], test_case: ) -def test_reset_with_mixed_states(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner): +def test_reset_with_mixed_states(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner) -> None: """Test reset with a mix of staged, unstaged, and untracked changes""" # 1. Staged modifications staged_changes = { @@ -348,7 +348,7 @@ def test_reset_with_mixed_states(committed_repo: Path, committed_state: dict[str ) -def test_reset_with_mixed_renames(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner): +def test_reset_with_mixed_renames(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner) -> None: """Test reset with a mix of staged and unstaged renames""" # 1. Staged rename staged_changes = { diff --git a/tests/unit/codegen/git/clients/test_git_repo_client.py b/tests/unit/codegen/git/clients/test_git_repo_client.py index c729dc9a6..d2b2cace0 100644 --- a/tests/unit/codegen/git/clients/test_git_repo_client.py +++ b/tests/unit/codegen/git/clients/test_git_repo_client.py @@ -7,7 +7,7 @@ @patch("codegen.git.clients.git_repo_client.GithubClientFactory") def test_delete_branch_default( mock_github_client_factory, -): +) -> None: git_repo_client = GitRepoClient(repo_config=MagicMock(), access_scope=GithubScope.WRITE) git_repo_client.read_client = MagicMock(default_branch="default-branch") git_repo_client.delete_branch(branch_name="default-branch") @@ -18,7 +18,7 @@ def test_delete_branch_default( @patch("codegen.git.clients.git_repo_client.GithubClientFactory") def test_delete_branch_non_default_branch( mock_github_client_factory, -): +) -> None: git_repo_client = GitRepoClient(repo_config=MagicMock(), access_scope=GithubScope.WRITE) git_repo_client.read_client = MagicMock(default_branch="default-branch") mock_ref = MagicMock() @@ -30,7 +30,7 @@ def test_delete_branch_non_default_branch( @patch("codegen.git.clients.git_repo_client.GithubClientFactory") def test_delete_branch_cannot_write_branch( mock_github_client_factory, -): +) -> None: git_repo_client = GitRepoClient(repo_config=MagicMock(), access_scope=GithubScope.WRITE) git_repo_client.read_client = MagicMock(default_branch="default-branch") git_repo_client.delete_branch(branch_name="not-default-branch") diff --git a/tests/unit/codegen/git/schemas/test_github.py b/tests/unit/codegen/git/schemas/test_github.py index 26d2b4d3a..a875b58ca 100644 --- a/tests/unit/codegen/git/schemas/test_github.py +++ b/tests/unit/codegen/git/schemas/test_github.py @@ -1,6 +1,6 @@ from codegen.git.schemas.github import GithubType -def test_github_type_base_url(): +def test_github_type_base_url() -> None: assert GithubType.Github.base_url == "https://github.com" assert GithubType.GithubEnterprise.base_url == "https://github.codegen.app" diff --git a/tests/unit/codegen/gscli/test_cli.py b/tests/unit/codegen/gscli/test_cli.py index 9c3356d96..96c11bdae 100644 --- a/tests/unit/codegen/gscli/test_cli.py +++ b/tests/unit/codegen/gscli/test_cli.py @@ -1,2 +1,2 @@ -def test_cli(): +def test_cli() -> None: import codegen.gscli # noqa: F401 diff --git a/tests/unit/codegen/runner/sandbox/test_executor.py b/tests/unit/codegen/runner/sandbox/test_executor.py index 0c1fa5f7a..60094b061 100644 --- a/tests/unit/codegen/runner/sandbox/test_executor.py +++ b/tests/unit/codegen/runner/sandbox/test_executor.py @@ -17,7 +17,7 @@ @pytest.mark.asyncio -async def test_execute_func_pass_in_codemod_context_takes_priority(executor: SandboxExecutor): +async def test_execute_func_pass_in_codemod_context_takes_priority(executor: SandboxExecutor) -> None: codemod_context = CodemodContext( CODEMOD_LINK="http://codegen.sh/codemod/5678", ) @@ -85,7 +85,7 @@ async def test_execute_func_pass_in_codemod_context_takes_priority(executor: San @pytest.mark.asyncio -async def test_run_max_preview_time_exceeded_sets_observation_meta(executor: SandboxExecutor): +async def test_run_max_preview_time_exceeded_sets_observation_meta(executor: SandboxExecutor) -> None: mock_source = """ codebase.files[0].edit("a = 2") """ @@ -97,7 +97,7 @@ async def test_run_max_preview_time_exceeded_sets_observation_meta(executor: San @pytest.mark.asyncio -async def test_run_max_ai_requests_error_sets_observation_meta(executor: SandboxExecutor): +async def test_run_max_ai_requests_error_sets_observation_meta(executor: SandboxExecutor) -> None: mock_source = """ codebase.ai("tell me a joke") """ @@ -109,7 +109,7 @@ async def test_run_max_ai_requests_error_sets_observation_meta(executor: Sandbox @pytest.mark.asyncio -async def test_run_max_transactions_exceeded_sets_observation_meta(executor: SandboxExecutor): +async def test_run_max_transactions_exceeded_sets_observation_meta(executor: SandboxExecutor) -> None: mock_source = """ codebase.files[0].edit("a = 2") """ @@ -122,7 +122,7 @@ async def test_run_max_transactions_exceeded_sets_observation_meta(executor: San @pytest.mark.asyncio -async def test_find_flag_groups_with_subdirectories(executor: SandboxExecutor): +async def test_find_flag_groups_with_subdirectories(executor: SandboxExecutor) -> None: groups = await executor.find_flag_groups( code_flags=[ CodeFlag( @@ -151,7 +151,7 @@ async def test_find_flag_groups_with_subdirectories(executor: SandboxExecutor): @pytest.mark.asyncio -async def test_find_flag_groups_with_group_by(executor: SandboxExecutor): +async def test_find_flag_groups_with_group_by(executor: SandboxExecutor) -> None: groups = await executor.find_flag_groups( code_flags=[ CodeFlag( @@ -185,7 +185,7 @@ async def test_find_flag_groups_with_group_by(executor: SandboxExecutor): @pytest.mark.asyncio @pytest.mark.parametrize("codebase", [121], indirect=True) -async def test_find_flag_groups_with_group_by_app(executor: SandboxExecutor): +async def test_find_flag_groups_with_group_by_app(executor: SandboxExecutor) -> None: groups = await executor.find_flag_groups( code_flags=[ CodeFlag( @@ -213,7 +213,7 @@ async def test_find_flag_groups_with_group_by_app(executor: SandboxExecutor): @pytest.mark.skip(reason="TODO: add max_prs as part of find_flag_groups") @pytest.mark.asyncio -async def test_find_flag_groups_with_max_prs(executor: SandboxExecutor): +async def test_find_flag_groups_with_max_prs(executor: SandboxExecutor) -> None: groups = await executor.find_flag_groups( code_flags=[ CodeFlag( diff --git a/tests/unit/codegen/runner/sandbox/test_runner.py b/tests/unit/codegen/runner/sandbox/test_runner.py index 0abd5c557..b1fb3a81d 100644 --- a/tests/unit/codegen/runner/sandbox/test_runner.py +++ b/tests/unit/codegen/runner/sandbox/test_runner.py @@ -7,7 +7,7 @@ @pytest.mark.asyncio @patch("codegen.runner.sandbox.executor.SandboxExecutor") -async def test_sandbox_runner_warmup_builds_graph(mock_executor, runner: SandboxRunner): +async def test_sandbox_runner_warmup_builds_graph(mock_executor, runner: SandboxRunner) -> None: await runner.warmup() assert runner.codebase.files assert len(runner.codebase.files) == 1 @@ -15,7 +15,7 @@ async def test_sandbox_runner_warmup_builds_graph(mock_executor, runner: Sandbox @pytest.mark.asyncio @patch("codegen.runner.sandbox.runner.SandboxRunner._build_graph") -async def test_sandbox_runner_warmup_builds_graph_throws(mock_build_graph, runner: SandboxRunner): +async def test_sandbox_runner_warmup_builds_graph_throws(mock_build_graph, runner: SandboxRunner) -> None: mock_build_graph.side_effect = Exception("Test exception") with pytest.raises(Exception): @@ -25,7 +25,7 @@ async def test_sandbox_runner_warmup_builds_graph_throws(mock_build_graph, runne @pytest.mark.asyncio @patch("codegen.runner.sandbox.runner.logger") @patch("codegen.runner.sandbox.runner.SandboxExecutor") -async def test_sandbox_runner_warmup_logs_repo_id(mock_executor, mock_logger, runner: SandboxRunner): +async def test_sandbox_runner_warmup_logs_repo_id(mock_executor, mock_logger, runner: SandboxRunner) -> None: await runner.warmup() assert runner.codebase.files assert len(runner.codebase.files) == 1 @@ -35,7 +35,7 @@ async def test_sandbox_runner_warmup_logs_repo_id(mock_executor, mock_logger, ru @pytest.mark.asyncio @patch("codegen.runner.sandbox.runner.SandboxExecutor") -async def test_sandbox_runner_warmup_starts_with_default_branch(mock_executor, runner: SandboxRunner): +async def test_sandbox_runner_warmup_starts_with_default_branch(mock_executor, runner: SandboxRunner) -> None: await runner.warmup() # assert True is returned # assert len(runner.codebase._op.git_cli.branches) == 1 TODO: fix GHA creating master and main branch assert not runner.codebase._op.git_cli.head.is_detached @@ -47,7 +47,7 @@ async def test_sandbox_runner_warmup_starts_with_default_branch(mock_executor, r @patch("codegen.runner.sandbox.runner.logger") @patch("codegen.runner.sandbox.runner.SandboxExecutor") @patch("codegen.sdk.core.codebase.Codebase.default_branch", new_callable=PropertyMock) -async def test_sandbox_runner_reset_runner_deletes_branches(mock_branch, mock_executor, mock_logger, runner: SandboxRunner): +async def test_sandbox_runner_reset_runner_deletes_branches(mock_branch, mock_executor, mock_logger, runner: SandboxRunner) -> None: mock_branch.return_value = "main" await runner.warmup() num_branches = len(runner.codebase._op.git_cli.heads) # TODO: fix GHA creating master and main branch and assert the len is 1 at the start diff --git a/tests/unit/codegen/runner/utils/test_branch_name.py b/tests/unit/codegen/runner/utils/test_branch_name.py index 6b3d807a5..7aae328db 100644 --- a/tests/unit/codegen/runner/utils/test_branch_name.py +++ b/tests/unit/codegen/runner/utils/test_branch_name.py @@ -3,13 +3,13 @@ from codegen.runner.utils.branch_name import get_head_branch_name -def test_get_head_branch_name_no_group(): +def test_get_head_branch_name_no_group() -> None: codemod = MagicMock(epic_id=123, version_id=456, run_id=789) branch_name = get_head_branch_name(codemod=codemod, group=None) assert branch_name == "codegen-codemod-123-version-456-run-789-group-0" -def test_get_head_branch_name_with_group(): +def test_get_head_branch_name_with_group() -> None: codemod = MagicMock(epic_id=123, version_id=456, run_id=789) group = MagicMock(id=2) branch_name = get_head_branch_name(codemod=codemod, group=group) diff --git a/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py b/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py index 3a8ebf689..f9f74fb1a 100644 --- a/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py +++ b/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py @@ -22,13 +22,13 @@ def setup_codebase(num_files: int, extension: str, tmp_path: Path): return codebase, files -def reset_codebase(codebase: Codebase): +def reset_codebase(codebase: Codebase) -> None: codebase.reset() @pytest.mark.benchmark(group="sdk-benchmark", min_time=1, max_time=5, disable_gc=True) @pytest.mark.parametrize("extension", ["txt", "py"]) -def test_codebase_reset_stress_test(extension: str, tmp_path, benchmark): +def test_codebase_reset_stress_test(extension: str, tmp_path, benchmark) -> None: def setup(): codebase, _ = setup_codebase(NUM_FILES, extension, tmp_path) return ((codebase,), {}) @@ -38,7 +38,7 @@ def setup(): @pytest.mark.timeout(5, func_only=True) @pytest.mark.parametrize("extension", ["txt", "py"]) -def test_codebase_reset_correctness(extension: str, tmp_path): +def test_codebase_reset_correctness(extension: str, tmp_path) -> None: codebase, files = setup_codebase(NUM_FILES, extension, tmp_path) codebase.reset() for file, original_content in files.items(): diff --git a/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py b/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py index 39e2fc20b..4e6b695c8 100644 --- a/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py +++ b/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py @@ -8,7 +8,7 @@ @pytest.mark.skip("broken after repo split, fix or move over") -def test_get_documented_objects(): +def test_get_documented_objects() -> None: """Test that importing everything in codegen-sdk doesn't invoke any functionality (incase someone leaves actual functionality at the top level of a file). diff --git a/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py b/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py index a084ae143..c61a26308 100644 --- a/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py +++ b/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py @@ -10,7 +10,7 @@ ], indirect=["original", "expected"], ) -def test_codebase_reset(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset(codebase: Codebase, assert_expected, tmp_path) -> None: # External change should be preserved (tmp_path / "a.py").write_text("b") # Programmatic change should be reset @@ -27,7 +27,7 @@ def test_codebase_reset(codebase: Codebase, assert_expected, tmp_path): ], indirect=["original", "expected"], ) -def test_codebase_reset_external_changes(codebase: Codebase, assert_expected): +def test_codebase_reset_external_changes(codebase: Codebase, assert_expected) -> None: # External change should be preserved codebase.get_file("a.py").path.write_text("b") codebase.commit() @@ -42,7 +42,7 @@ def test_codebase_reset_external_changes(codebase: Codebase, assert_expected): ], indirect=["original", "expected"], ) -def test_codebase_reset_manual_file_add(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset_manual_file_add(codebase: Codebase, assert_expected, tmp_path) -> None: # Manually create a new file - should be preserved new_file = tmp_path / "new.py" new_file.write_text("new content") @@ -60,7 +60,7 @@ def test_codebase_reset_manual_file_add(codebase: Codebase, assert_expected, tmp ], indirect=["original", "expected"], ) -def test_codebase_reset_manual_file_delete(codebase: Codebase, assert_expected): +def test_codebase_reset_manual_file_delete(codebase: Codebase, assert_expected) -> None: # Manual deletion should be preserved codebase.get_file("b.py").path.unlink() # Programmatic change should be reset @@ -77,7 +77,7 @@ def test_codebase_reset_manual_file_delete(codebase: Codebase, assert_expected): ], indirect=["original", "expected"], ) -def test_codebase_reset_manual_file_rename(codebase: Codebase, tmp_path, assert_expected): +def test_codebase_reset_manual_file_rename(codebase: Codebase, tmp_path, assert_expected) -> None: # Manual rename should be preserved old_path = codebase.get_file("old.py").path new_path = tmp_path / "new.py" @@ -104,7 +104,7 @@ def test_codebase_reset_manual_file_rename(codebase: Codebase, tmp_path, assert_ ], indirect=["original", "expected"], ) -def test_codebase_reset_nested_directories(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset_nested_directories(codebase: Codebase, assert_expected, tmp_path) -> None: """Test reset with nested directory structure.""" # External changes should be preserved (tmp_path / "src/main.py").write_text("def main():\n print('modified')") @@ -133,7 +133,7 @@ def test_codebase_reset_nested_directories(codebase: Codebase, assert_expected, ], indirect=["original", "expected"], ) -def test_codebase_reset_mixed_content(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset_mixed_content(codebase: Codebase, assert_expected, tmp_path) -> None: """Test reset with different types of file content.""" # External changes should be preserved (tmp_path / "config.json").write_text('{\n "debug": false,\n "env": "prod"\n}') @@ -187,7 +187,7 @@ def reset(self): ], indirect=["original", "expected"], ) -def test_codebase_reset_large_file(codebase: Codebase, assert_expected): +def test_codebase_reset_large_file(codebase: Codebase, assert_expected) -> None: """Test reset with a larger file containing multiple methods.""" codebase.get_file("module.py").edit("""class ModifiedClass: def __init__(self): @@ -204,7 +204,7 @@ def __init__(self): ], indirect=["original", "expected"], ) -def test_codebase_reset_preserves_external_changes(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset_preserves_external_changes(codebase: Codebase, assert_expected, tmp_path) -> None: # Make external changes to existing file src_dir = tmp_path / "src" src_dir.mkdir(exist_ok=True) @@ -229,7 +229,7 @@ def test_codebase_reset_preserves_external_changes(codebase: Codebase, assert_ex ], indirect=["original", "expected"], ) -def test_codebase_reset_mixed_changes(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset_mixed_changes(codebase: Codebase, assert_expected, tmp_path) -> None: # Make programmatic change that should be reset codebase.get_file("src/utils.py").edit("def helper():\n return None") @@ -250,7 +250,7 @@ def test_codebase_reset_mixed_changes(codebase: Codebase, assert_expected, tmp_p ], indirect=["original", "expected"], ) -def test_codebase_reset_nested_external_changes(codebase: Codebase, assert_expected, tmp_path): +def test_codebase_reset_nested_external_changes(codebase: Codebase, assert_expected, tmp_path) -> None: # Create nested directory structure with changes config_dir = tmp_path / "config" config_dir.mkdir(exist_ok=True) @@ -277,7 +277,7 @@ def test_codebase_reset_nested_external_changes(codebase: Codebase, assert_expec ], indirect=["original", "expected"], ) -def test_codebase_reset_multiple_programmatic_edits(codebase: Codebase, assert_expected): +def test_codebase_reset_multiple_programmatic_edits(codebase: Codebase, assert_expected) -> None: """Test reset after multiple programmatic edits to the same file.""" # Make multiple programmatic changes that should all be reset codebase.get_file("file.py").edit("first edit") @@ -302,7 +302,7 @@ def test_codebase_reset_multiple_programmatic_edits(codebase: Codebase, assert_e ], indirect=["original", "expected"], ) -def test_codebase_reset_interleaved_changes(codebase: Codebase, assert_expected): +def test_codebase_reset_interleaved_changes(codebase: Codebase, assert_expected) -> None: """Test reset with interleaved programmatic and external changes.""" # Interleave programmatic and external changes codebase.get_file("file.py").edit("def main():\n return 1") @@ -335,7 +335,7 @@ def method1(self): ], indirect=["original", "expected"], ) -def test_codebase_reset_complex_changes(codebase: Codebase, assert_expected): +def test_codebase_reset_complex_changes(codebase: Codebase, assert_expected) -> None: """Test reset with a mix of content additions, modifications, and external changes.""" # Make several programmatic changes for i in range(5): diff --git a/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py b/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py index 5eb6e77e2..017f1163d 100644 --- a/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py +++ b/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py @@ -6,7 +6,7 @@ from codegen.sdk.python import PyFile -def test_parent_statement_function(tmpdir): +def test_parent_statement_function(tmpdir) -> None: # language=python content = """ def foo(): @@ -17,7 +17,7 @@ def foo(): assert codebase.get_function("foo").parent_statement == file.code_block.statements[0] -def test_parent_statement_class(tmpdir): +def test_parent_statement_class(tmpdir) -> None: # language=python content = """ class Foo: @@ -28,7 +28,7 @@ class Foo: assert codebase.get_class("Foo").parent_statement == file.code_block.statements[0] -def test_parent_statement_assignment(tmpdir): +def test_parent_statement_assignment(tmpdir) -> None: # language=python content = """ foo = 1 @@ -38,7 +38,7 @@ def test_parent_statement_assignment(tmpdir): assert file.get_global_var("foo").parent_statement == file.code_block.statements[0] -def test_parent_statement_nested_symbols(tmpdir): +def test_parent_statement_nested_symbols(tmpdir) -> None: # language=python content = """ logger = get_logger() diff --git a/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py b/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py index d7beba6ec..1491360a6 100644 --- a/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py +++ b/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py @@ -2,7 +2,7 @@ from codegen.sdk.codebase.flagging.enums import MessageType -def test_code_flag_properties(tmpdir): +def test_code_flag_properties(tmpdir) -> None: # language=python content = """ class Foo: diff --git a/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py b/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py index 179a6ffb2..be07f8c93 100644 --- a/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py +++ b/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py @@ -4,7 +4,7 @@ from codegen.sdk.codebase.flagging.groupers.all_grouper import AllGrouper -def test_group_all(): +def test_group_all() -> None: flag1 = CodeFlag( symbol=MagicMock( file=MagicMock(filepath="test.py"), diff --git a/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py b/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py index 807559392..b3c30ae73 100644 --- a/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py +++ b/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py @@ -6,7 +6,7 @@ from codegen.shared.exceptions.control_flow import MaxPreviewTimeExceeded, MaxTransactionsExceeded -def test_check_max_preview_time_exceeded(tmpdir): +def test_check_max_preview_time_exceeded(tmpdir) -> None: with pytest.raises(MaxPreviewTimeExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -20,7 +20,7 @@ def test_check_max_preview_time_exceeded(tmpdir): assert exc_info.value.threshold == 0 -def test_check_max_preview_time_exceeded_set_session_options(tmpdir): +def test_check_max_preview_time_exceeded_set_session_options(tmpdir) -> None: with get_codebase_session( tmpdir=tmpdir, files={"file_a.py": "a = 1", "file_b": "b = 1"}, @@ -34,7 +34,7 @@ def test_check_max_preview_time_exceeded_set_session_options(tmpdir): assert exc_info.value.threshold == 0 -def test_check_max_transactions_exceeded(tmpdir): +def test_check_max_transactions_exceeded(tmpdir) -> None: with pytest.raises(MaxTransactionsExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -48,7 +48,7 @@ def test_check_max_transactions_exceeded(tmpdir): assert exc_info.value.threshold == 0 -def test_check_max_transactions_exceeded_set_session_options(tmpdir): +def test_check_max_transactions_exceeded_set_session_options(tmpdir) -> None: with get_codebase_session( tmpdir=tmpdir, files={"file_a.py": "a = 1", "file_b": "b = 1"}, diff --git a/tests/unit/codegen/sdk/conftest.py b/tests/unit/codegen/sdk/conftest.py index a9b12f9a5..03162cc4a 100644 --- a/tests/unit/codegen/sdk/conftest.py +++ b/tests/unit/codegen/sdk/conftest.py @@ -28,7 +28,7 @@ def codebase(tmp_path, original: dict[str, str], programming_language: Programmi @pytest.fixture def assert_expected(expected: dict[str, str], tmp_path): - def assert_expected(codebase: Codebase): + def assert_expected(codebase: Codebase) -> None: codebase.commit() for file in expected: assert tmp_path.joinpath(file).exists() diff --git a/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py b/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py index a183ea2ef..8aedd9ba3 100644 --- a/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py +++ b/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py @@ -4,7 +4,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_python_exports_not_supported(tmpdir): +def test_python_exports_not_supported(tmpdir) -> None: """Test that exports are not supported in Python codebases.""" # language=python content = """ diff --git a/tests/unit/codegen/sdk/python/codebase/test_control_flow.py b/tests/unit/codegen/sdk/python/codebase/test_control_flow.py index 589f2a2fd..4aaa7c5dc 100644 --- a/tests/unit/codegen/sdk/python/codebase/test_control_flow.py +++ b/tests/unit/codegen/sdk/python/codebase/test_control_flow.py @@ -1,3 +1,5 @@ +from typing import NoReturn + import pytest from codegen.sdk.codebase.config import SessionOptions @@ -7,13 +9,13 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_max_transactions_exceeded_reached_set_threshold(tmpdir): +def test_max_transactions_exceeded_reached_set_threshold(tmpdir) -> None: e = MaxTransactionsExceeded("test exception", threshold=1) assert str(e) == "test exception" assert e.threshold == 1 -def test_raise_max_transactions_exceeded_reached_no_threshold(tmpdir): +def test_raise_max_transactions_exceeded_reached_no_threshold(tmpdir) -> NoReturn: with pytest.raises(MaxTransactionsExceeded) as exc_info: msg = "test exception" raise MaxTransactionsExceeded(msg) @@ -21,7 +23,7 @@ def test_raise_max_transactions_exceeded_reached_no_threshold(tmpdir): assert exc_info.value.threshold is None -def test_raise_max_transactions_exceeded_reached_with_threshold(tmpdir): +def test_raise_max_transactions_exceeded_reached_with_threshold(tmpdir) -> NoReturn: with pytest.raises(MaxTransactionsExceeded) as exc_info: msg = "test exception" raise MaxTransactionsExceeded(msg, threshold=1) @@ -29,7 +31,7 @@ def test_raise_max_transactions_exceeded_reached_with_threshold(tmpdir): assert exc_info.value.threshold == 1 -def test_max_transactions_exceeded_reached(tmpdir): +def test_max_transactions_exceeded_reached(tmpdir) -> None: with pytest.raises(MaxTransactionsExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -43,7 +45,7 @@ def test_max_transactions_exceeded_reached(tmpdir): assert exc_info.value.threshold == 1 -def test_max_transactions_exceeded_reached_should_still_commit(tmpdir): +def test_max_transactions_exceeded_reached_should_still_commit(tmpdir) -> None: with pytest.raises(MaxTransactionsExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -59,7 +61,7 @@ def test_max_transactions_exceeded_reached_should_still_commit(tmpdir): assert exc_info.value.threshold == 1 -def test_max_preview_time_exceeded_reached(tmpdir): +def test_max_preview_time_exceeded_reached(tmpdir) -> None: with pytest.raises(MaxPreviewTimeExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -73,7 +75,7 @@ def test_max_preview_time_exceeded_reached(tmpdir): assert exc_info.value.threshold == 0 -def test_max_ai_requests_error_reached(tmpdir): +def test_max_ai_requests_error_reached(tmpdir) -> None: with pytest.raises(MaxAIRequestsError) as exc_info: with get_codebase_session( tmpdir=tmpdir, diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py index 4bd8a726f..13d38ea7e 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py @@ -7,7 +7,7 @@ from codegen.sdk.python import PyFile -def test_indent_left_once(tmpdir): +def test_indent_left_once(tmpdir) -> None: # language=python content = """ def foo(): @@ -32,7 +32,7 @@ def foo(): ) -def test_indent_left_exceed_limit(tmpdir): +def test_indent_left_exceed_limit(tmpdir) -> None: # language=python content = """ def foo(): @@ -57,7 +57,7 @@ def foo(): ) -def test_indent_right_once(tmpdir): +def test_indent_right_once(tmpdir) -> None: # language=python content = """ def foo(): @@ -82,7 +82,7 @@ def foo(): ) -def test_indent_right_multiple(tmpdir): +def test_indent_right_multiple(tmpdir) -> None: # language=python content = """ def foo(): @@ -107,7 +107,7 @@ def foo(): ) -def test_indent_zero(tmpdir): +def test_indent_zero(tmpdir) -> None: # language=python content = """ def foo(): @@ -122,7 +122,7 @@ def foo(): assert file.content == content -def test_indent_nested_code_blocks(tmpdir): +def test_indent_nested_code_blocks(tmpdir) -> None: # language=python content = """ def foo(): @@ -181,7 +181,7 @@ def foo(): ) -def test_indent_only_nested_block(tmpdir): +def test_indent_only_nested_block(tmpdir) -> None: # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py index 1b29bb754..d96496c04 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py @@ -1,7 +1,7 @@ from codegen.sdk.codebase.factory.get_session import get_codebase_session -def test_code_block_append_single_element(tmpdir): +def test_code_block_append_single_element(tmpdir) -> None: # language=python content = """ def foo(): @@ -27,7 +27,7 @@ def foo(): ) -def test_code_block_append_multiple_element(tmpdir): +def test_code_block_append_multiple_element(tmpdir) -> None: # language=python content = """ def foo(): @@ -55,7 +55,7 @@ def foo(): ) -def test_code_block_insert_single_element_beginning(tmpdir): +def test_code_block_insert_single_element_beginning(tmpdir) -> None: # language=python content = """ def foo(): @@ -81,7 +81,7 @@ def foo(): ) -def test_code_block_insert_multiple_element_beginning(tmpdir): +def test_code_block_insert_multiple_element_beginning(tmpdir) -> None: # language=python content = """ def foo(): @@ -109,7 +109,7 @@ def foo(): ) -def test_code_block_insert_single_element_middle(tmpdir): +def test_code_block_insert_single_element_middle(tmpdir) -> None: # language=python content = """ def foo(): @@ -135,7 +135,7 @@ def foo(): ) -def test_code_block_insert_multiple_element_middle(tmpdir): +def test_code_block_insert_multiple_element_middle(tmpdir) -> None: # language=python content = """ def foo(): @@ -163,7 +163,7 @@ def foo(): ) -def test_code_block_insert_single_element_end(tmpdir): +def test_code_block_insert_single_element_end(tmpdir) -> None: # language=python content = """ def foo(): @@ -189,7 +189,7 @@ def foo(): ) -def test_code_block_insert_multiple_element_end(tmpdir): +def test_code_block_insert_multiple_element_end(tmpdir) -> None: # language=python content = """ def foo(): @@ -217,7 +217,7 @@ def foo(): ) -def test_code_block_insert_multiple_out_of_order(tmpdir): +def test_code_block_insert_multiple_out_of_order(tmpdir) -> None: # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py index 5c58933eb..41a0d8349 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py @@ -1,7 +1,7 @@ from codegen.sdk.codebase.factory.get_session import get_codebase_session -def test_code_block_remove_multiple_element(tmpdir): +def test_code_block_remove_multiple_element(tmpdir) -> None: # language=python content = """ def foo(): @@ -25,7 +25,7 @@ def foo(): ) -def test_code_block_remove_insert_beginning(tmpdir): +def test_code_block_remove_insert_beginning(tmpdir) -> None: # language=python content = """ def foo(): @@ -51,7 +51,7 @@ def foo(): ) -def test_code_block_insert_remove_beginning(tmpdir): +def test_code_block_insert_remove_beginning(tmpdir) -> None: # language=python content = """ def foo(): @@ -77,7 +77,7 @@ def foo(): ) -def test_code_block_remove_insert_middle(tmpdir): +def test_code_block_remove_insert_middle(tmpdir) -> None: # language=python content = """ def foo(): @@ -103,7 +103,7 @@ def foo(): ) -def test_code_block_insert_remove_middle(tmpdir): +def test_code_block_insert_remove_middle(tmpdir) -> None: # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py index df9419975..8bf67b3eb 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py @@ -7,7 +7,7 @@ from codegen.sdk.python import PyFile -def test_unwrap_flat_statements(tmpdir): +def test_unwrap_flat_statements(tmpdir) -> None: # language=python content = """ def foo(): @@ -36,7 +36,7 @@ def foo(): ) -def test_unwrap_nested_statements(tmpdir): +def test_unwrap_nested_statements(tmpdir) -> None: # language=python content = """ def foo(): @@ -72,7 +72,7 @@ def foo(): ) -def test_unwrap_sandwiched_statements(tmpdir): +def test_unwrap_sandwiched_statements(tmpdir) -> None: # language=python content = """ def foo(): @@ -108,7 +108,7 @@ def foo(): ) -def test_unwrap_multiline_wrapper(tmpdir): +def test_unwrap_multiline_wrapper(tmpdir) -> None: # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py index 046be8ff5..5fbd475ed 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py @@ -6,7 +6,7 @@ from codegen.sdk.python import PyFile -def test_wrap_with_with_statement(tmpdir): +def test_wrap_with_with_statement(tmpdir) -> None: # language=python content = """ def foo(a: bool): @@ -33,7 +33,7 @@ def foo(a: bool): ) -def test_wrap_with_function(tmpdir): +def test_wrap_with_function(tmpdir) -> None: # language=python content = """ if a: diff --git a/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py b/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py index 9dd786afa..e6dc799b2 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py @@ -10,7 +10,7 @@ from codegen.sdk.python.statements.if_block_statement import PyIfBlockStatement -def test_function_calls_from_file(tmpdir): +def test_function_calls_from_file(tmpdir) -> None: # language=python content = """ from some_file import x, y, z @@ -45,7 +45,7 @@ def random(): ] -def test_function_calls_from_class(tmpdir): +def test_function_calls_from_class(tmpdir) -> None: # language=python content = """ from some_file import bar @@ -86,7 +86,7 @@ def foo(self): assert third_call.parent.statement_type == StatementType.RETURN_STATEMENT -def test_function_calls_from_decorated_definitions(tmpdir): +def test_function_calls_from_decorated_definitions(tmpdir) -> None: # language=python content = """ @pytest.mark.parametrize("x", [1, 2, 3]) @@ -124,7 +124,7 @@ def __init__(self): @pytest.mark.xfail(reason="Broken by function call changes") -def test_function_calls_from_datatypes(tmpdir): +def test_function_calls_from_datatypes(tmpdir) -> None: # language=python content = """ def get_config(): @@ -168,7 +168,7 @@ def get_config(): ] -def test_function_calls_from_function_parameters(tmpdir): +def test_function_calls_from_function_parameters(tmpdir) -> None: # language=python content = """ # function parameters @@ -189,7 +189,7 @@ def greet(name=get_default_name()): ] -def test_function_calls_from_while_loop(tmpdir): +def test_function_calls_from_while_loop(tmpdir) -> None: # language=python content = """ # while loop conditions @@ -209,7 +209,7 @@ def test_function_calls_from_while_loop(tmpdir): ] -def test_function_calls_from_if_conditions(tmpdir): +def test_function_calls_from_if_conditions(tmpdir) -> None: # language=python content = """ # if conditions @@ -233,7 +233,7 @@ def test_function_calls_from_if_conditions(tmpdir): ] -def test_function_calls_from_with_clause(tmpdir): +def test_function_calls_from_with_clause(tmpdir) -> None: # language=python content = """ # with clause @@ -255,5 +255,5 @@ def test_function_calls_from_with_clause(tmpdir): @pytest.mark.skip(reason="Ellen: why is this test empty?") -def test_function_calls_from_function_calls(tmpdir): +def test_function_calls_from_function_calls(tmpdir) -> None: pass diff --git a/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py b/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py index 918d7d171..2725ffbfc 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py +++ b/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py @@ -9,7 +9,7 @@ from codegen.sdk.python import PyFile -def test_all_binary_expression_types(tmpdir): +def test_all_binary_expression_types(tmpdir) -> None: # language=python content = """ a = 1 + 2 @@ -133,7 +133,7 @@ def test_all_binary_expression_types(tmpdir): assert file.get_global_var("w").value.operator.source == "in" -def test_chained_binary_expressions(tmpdir): +def test_chained_binary_expressions(tmpdir) -> None: # language=python content = """ a = 1 + 2 - 3 * 4 / 5 % 6 ** 7 // 8 # binary operators @@ -157,7 +157,7 @@ def test_chained_binary_expressions(tmpdir): @pytest.mark.skip(reason="CG-8883: Parenthesized expressions not implemented yet") -def test_chained_multiline_binary_expressions_using_parenthesis(tmpdir): +def test_chained_multiline_binary_expressions_using_parenthesis(tmpdir) -> None: # language=python content = """ a = (1 + 2 - 3 * 4 @@ -185,7 +185,7 @@ def test_chained_multiline_binary_expressions_using_parenthesis(tmpdir): assert [x.source for x in c.operators] == ["and", "or", "and", "or"] -def test_chained_multiline_binary_expressions_using_backslash(tmpdir): +def test_chained_multiline_binary_expressions_using_backslash(tmpdir) -> None: # language=python content = """ a = 1 + 2 - 3 * 4 \ @@ -214,7 +214,7 @@ def test_chained_multiline_binary_expressions_using_backslash(tmpdir): @pytest.mark.skip(reason="CG-8886: Mixed expression groups not implemented yet") -def test_chained_mixed_binary_expressions(tmpdir): +def test_chained_mixed_binary_expressions(tmpdir) -> None: # language=python content = """ a = 1 + 2 == True != False or True and False * 12 @@ -238,7 +238,7 @@ def test_chained_mixed_binary_expressions(tmpdir): @pytest.mark.skip(reason="CG-8883: Parenthesized expressions not implemented yet") -def test_chained_mixed_multiline_binary_expressions_with_parenthesis(tmpdir): +def test_chained_mixed_multiline_binary_expressions_with_parenthesis(tmpdir) -> None: # language=python content = """ a = (1 + 2 == True @@ -253,7 +253,7 @@ def test_chained_mixed_multiline_binary_expressions_with_parenthesis(tmpdir): @pytest.mark.skip(reason="CG-8886: Mixed expression groups not implemented yet") -def test_chained_mixed_multiline_binary_expressions_with_backslash(tmpdir): +def test_chained_mixed_multiline_binary_expressions_with_backslash(tmpdir) -> None: # language=python content = """ a = 1 + 2 == True \ diff --git a/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py b/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py index 1e63e0fd1..d3aef419c 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py +++ b/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py @@ -7,7 +7,7 @@ from codegen.sdk.python.file import PyFile -def test_reduce_binary_simple(tmpdir): +def test_reduce_binary_simple(tmpdir) -> None: # language=python content = """ def foo(): @@ -31,7 +31,7 @@ def foo(): ) -def test_reduce_binary_complex_condition(tmpdir): +def test_reduce_binary_complex_condition(tmpdir) -> None: # language=python content = """ def bar(): @@ -58,7 +58,7 @@ def bar(): ) -def test_reduce_negation_condition(tmpdir): +def test_reduce_negation_condition(tmpdir) -> None: # language=python content = """ def baz(): @@ -84,7 +84,7 @@ def baz(): ) -def test_reduce_binary_with_string(tmpdir): +def test_reduce_binary_with_string(tmpdir) -> None: # language=python content = """ def qux(): @@ -108,7 +108,7 @@ def qux(): ) -def test_reduce_complex_condition_with_string(tmpdir): +def test_reduce_complex_condition_with_string(tmpdir) -> None: # language=python content = """ def quux(): diff --git a/tests/unit/codegen/sdk/python/expressions/test_boolean.py b/tests/unit/codegen/sdk/python/expressions/test_boolean.py index 51ac48ecb..cf3777914 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_boolean.py +++ b/tests/unit/codegen/sdk/python/expressions/test_boolean.py @@ -5,7 +5,7 @@ from codegen.sdk.python.assignment import PyAssignment -def test_boolean_parse(tmpdir): +def test_boolean_parse(tmpdir) -> None: # language=python content = """ a = True diff --git a/tests/unit/codegen/sdk/python/expressions/test_number.py b/tests/unit/codegen/sdk/python/expressions/test_number.py index 1452f1477..30cc9cf5a 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_number.py +++ b/tests/unit/codegen/sdk/python/expressions/test_number.py @@ -3,7 +3,7 @@ from codegen.sdk.core.expressions.number import Number -def test_number_parse(tmpdir): +def test_number_parse(tmpdir) -> None: # language=python content = """ a = 1 diff --git a/tests/unit/codegen/sdk/python/expressions/test_type.py b/tests/unit/codegen/sdk/python/expressions/test_type.py index 22cd7f8f5..a90325d16 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_type.py +++ b/tests/unit/codegen/sdk/python/expressions/test_type.py @@ -9,7 +9,7 @@ from codegen.sdk.python import PyAssignment, PyClass, PyFunction -def test_type_basic(tmpdir): +def test_type_basic(tmpdir) -> None: file = "test.py" # language=python content = """ @@ -35,7 +35,7 @@ def foo(a: str): ) -def test_type_generic(tmpdir): +def test_type_generic(tmpdir) -> None: file = "test.py" # language=python content = """ @@ -63,7 +63,7 @@ def foo(a: tuple[int, int, str]): ) -def test_type_union(tmpdir): +def test_type_union(tmpdir) -> None: file = "test.py" # language=python content = """ @@ -90,7 +90,7 @@ def foo(a: int | None | str): ) -def test_type_multi_file(tmpdir): +def test_type_multi_file(tmpdir) -> None: file2 = "test2.py" # language=python content2 = """ diff --git a/tests/unit/codegen/sdk/python/function/test_function_async.py b/tests/unit/codegen/sdk/python/function/test_function_async.py index 796b323b7..79bceadc0 100644 --- a/tests/unit/codegen/sdk/python/function/test_function_async.py +++ b/tests/unit/codegen/sdk/python/function/test_function_async.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_function_is_async_basic(tmpdir): +def test_function_is_async_basic(tmpdir) -> None: # language=python content = """ def foo(): @@ -56,7 +56,7 @@ async def qux(self): ) -def test_function_is_async_extended(tmpdir): +def test_function_is_async_extended(tmpdir) -> None: # language=python content = """ @my_decorator diff --git a/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py b/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py index c31f55f22..fd3d817d8 100644 --- a/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py +++ b/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_py_import_is_dynamic_in_function(tmpdir): +def test_py_import_is_dynamic_in_function(tmpdir) -> None: # language=python content = """ def my_function(): @@ -23,7 +23,7 @@ def my_function(): assert not imports[2].is_dynamic # import static_import -def test_py_import_is_dynamic_in_if_block(tmpdir): +def test_py_import_is_dynamic_in_if_block(tmpdir) -> None: # language=python content = """ import top_level # Static import @@ -41,7 +41,7 @@ def test_py_import_is_dynamic_in_if_block(tmpdir): assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_try_except(tmpdir): +def test_py_import_is_dynamic_in_try_except(tmpdir) -> None: # language=python content = """ import static_first # Static import @@ -61,7 +61,7 @@ def test_py_import_is_dynamic_in_try_except(tmpdir): assert imports[2].is_dynamic # from x.y import z -def test_py_import_is_dynamic_in_with_block(tmpdir): +def test_py_import_is_dynamic_in_with_block(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -79,7 +79,7 @@ def test_py_import_is_dynamic_in_with_block(tmpdir): assert imports[2].is_dynamic # from a.b import c -def test_py_import_is_dynamic_in_class_method(tmpdir): +def test_py_import_is_dynamic_in_class_method(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -103,7 +103,7 @@ def class_method(cls): assert imports[3].is_dynamic # another_dynamic import -def test_py_import_is_dynamic_in_nested_function(tmpdir): +def test_py_import_is_dynamic_in_nested_function(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -125,7 +125,7 @@ def inner_function(): assert imports[3].is_dynamic # from x import y -def test_py_import_is_dynamic_in_else_clause(tmpdir): +def test_py_import_is_dynamic_in_else_clause(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -145,7 +145,7 @@ def test_py_import_is_dynamic_in_else_clause(tmpdir): assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_except_clause(tmpdir): +def test_py_import_is_dynamic_in_except_clause(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -165,7 +165,7 @@ def test_py_import_is_dynamic_in_except_clause(tmpdir): assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_finally_clause(tmpdir): +def test_py_import_is_dynamic_in_finally_clause(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -187,7 +187,7 @@ def test_py_import_is_dynamic_in_finally_clause(tmpdir): assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_while_statement(tmpdir): +def test_py_import_is_dynamic_in_while_statement(tmpdir) -> None: # language=python content = """ import static_import # Static import @@ -205,7 +205,7 @@ def test_py_import_is_dynamic_in_while_statement(tmpdir): assert imports[2].is_dynamic # from a import b -def test_py_import_is_dynamic_in_match_case(tmpdir): +def test_py_import_is_dynamic_in_match_case(tmpdir) -> None: # language=python content = """ import static_import # Static import diff --git a/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py b/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py index d1eaecd13..d8141f0ea 100644 --- a/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py +++ b/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py @@ -9,7 +9,7 @@ from codegen.sdk.python import PyFile -def test_reduce_condition_to_true_elif(tmpdir): +def test_reduce_condition_to_true_elif(tmpdir) -> None: # language=python content = """ def foo(): @@ -41,7 +41,7 @@ def foo(): ) -def test_reduce_condition_to_false_elif(tmpdir): +def test_reduce_condition_to_false_elif(tmpdir) -> None: # language=python content = """ def foo(): @@ -71,7 +71,7 @@ def foo(): ) -def test_reduce_condition_to_true_else(tmpdir): +def test_reduce_condition_to_true_else(tmpdir) -> None: # language=python content = """ def foo(): @@ -97,7 +97,7 @@ def foo(): ) -def test_reduce_condition_to_false_else(tmpdir): +def test_reduce_condition_to_false_else(tmpdir) -> None: # language=python content = """ def foo(): @@ -123,7 +123,7 @@ def foo(): ) -def test_reduce_condition_multiple_if_blocks(tmpdir): +def test_reduce_condition_multiple_if_blocks(tmpdir) -> None: # language=python content = """ def foo(): @@ -155,7 +155,7 @@ def foo(): ) -def test_reduce_condition_nested_if(tmpdir): +def test_reduce_condition_nested_if(tmpdir) -> None: # language=python content = """ class MyClass: @@ -198,7 +198,7 @@ def foo(self): ) -def test_reduce_condition_else_if_to_true(tmpdir): +def test_reduce_condition_else_if_to_true(tmpdir) -> None: # language=python content = """ def foo(): @@ -234,7 +234,7 @@ def foo(): ) -def test_reduce_condition_else_if_to_false(tmpdir): +def test_reduce_condition_else_if_to_false(tmpdir) -> None: # language=python content = """ def foo(): @@ -268,7 +268,7 @@ def foo(): ) -def test_reduce_condition_second_else_if_to_true(tmpdir): +def test_reduce_condition_second_else_if_to_true(tmpdir) -> None: # language=python content = """ def foo(): @@ -300,7 +300,7 @@ def foo(): ) -def test_reduce_condition_second_else_if_to_false(tmpdir): +def test_reduce_condition_second_else_if_to_false(tmpdir) -> None: # language=python content = """ def foo(): @@ -332,7 +332,7 @@ def foo(): ) -def test_reduce_condition_else_statement_raises(tmpdir): +def test_reduce_condition_else_statement_raises(tmpdir) -> None: # language=python content = """ def foo(): @@ -351,7 +351,7 @@ def foo(): else_block.reduce_condition(True) -def test_reduce_condition_to_true_single_if(tmpdir): +def test_reduce_condition_to_true_single_if(tmpdir) -> None: # language=python content = """ def foo(): @@ -375,7 +375,7 @@ def foo(): ) -def test_reduce_condition_to_false_single_if(tmpdir): +def test_reduce_condition_to_false_single_if(tmpdir) -> None: # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py b/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py index db139e11e..45b129002 100644 --- a/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py +++ b/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py @@ -8,7 +8,7 @@ from codegen.sdk.python import PyFile -def test_with_statement_single_var(tmpdir): +def test_with_statement_single_var(tmpdir) -> None: # language=python content = """ def foo(): @@ -38,7 +38,7 @@ def foo(): ) -def test_with_statement_aliased_var(tmpdir): +def test_with_statement_aliased_var(tmpdir) -> None: # language=python content = """ def foo(): @@ -67,7 +67,7 @@ def foo(): ) -def test_with_statement_multiple_vars(tmpdir): +def test_with_statement_multiple_vars(tmpdir) -> None: # language=python content = """ def foo(): @@ -96,7 +96,7 @@ def foo(): ) -def test_with_statement_multiline_vars(tmpdir): +def test_with_statement_multiline_vars(tmpdir) -> None: # language=python content = """ def foo(): @@ -137,7 +137,7 @@ def foo(): ) -def test_with_statement_function_call(tmpdir): +def test_with_statement_function_call(tmpdir) -> None: # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py index 35e7622be..e0e63548d 100644 --- a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py +++ b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py @@ -3,7 +3,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_indent_once_to_left(tmpdir): +def test_indent_once_to_left(tmpdir) -> None: # language=typescript content = """ function foo(): number { @@ -30,7 +30,7 @@ def test_indent_once_to_left(tmpdir): ) -def test_indent_left_exceed_limit(tmpdir): +def test_indent_left_exceed_limit(tmpdir) -> None: # language=typescript content = """ function foo(): number { @@ -57,7 +57,7 @@ def test_indent_left_exceed_limit(tmpdir): ) -def test_indent_right_once(tmpdir): +def test_indent_right_once(tmpdir) -> None: # language=typescript content = """ function foo(): number { @@ -84,7 +84,7 @@ def test_indent_right_once(tmpdir): ) -def test_indent_right_multiple(tmpdir): +def test_indent_right_multiple(tmpdir) -> None: # language=typescript content = """ function foo(): number { @@ -111,7 +111,7 @@ def test_indent_right_multiple(tmpdir): ) -def test_indent_zero(tmpdir): +def test_indent_zero(tmpdir) -> None: # language=typescript content = """ function foo(): number { @@ -128,7 +128,7 @@ def test_indent_zero(tmpdir): assert file.content == content -def test_indent_nested_code_blocks(tmpdir): +def test_indent_nested_code_blocks(tmpdir) -> None: # language=typescript content = """ function foo(): number { @@ -201,7 +201,7 @@ def test_indent_nested_code_blocks(tmpdir): ) -def test_indent_only_nested_block(tmpdir): +def test_indent_only_nested_block(tmpdir) -> None: # language=typescript content = """ function foo(a: boolean, b: any, c: any, d: boolean): void { diff --git a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py index 0ebccc5b5..e37d109dd 100644 --- a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py +++ b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py @@ -8,7 +8,7 @@ from codegen.sdk.typescript.file import TSFile -def test_unwrap_flat_statements(tmpdir): +def test_unwrap_flat_statements(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -40,7 +40,7 @@ def test_unwrap_flat_statements(tmpdir): ) -def test_unwrap_nested_statements(tmpdir): +def test_unwrap_nested_statements(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -83,7 +83,7 @@ def test_unwrap_nested_statements(tmpdir): ) -def test_unwrap_sandwiched_statements(tmpdir): +def test_unwrap_sandwiched_statements(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -124,7 +124,7 @@ def test_unwrap_sandwiched_statements(tmpdir): ) -def test_unwrap_multiline_wrapper(tmpdir): +def test_unwrap_multiline_wrapper(tmpdir) -> None: # language=typescript content = """ function foo(): void { diff --git a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py index 0a52dece6..2b3c805bf 100644 --- a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py +++ b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_wrap_with_if_statement(tmpdir): +def test_wrap_with_if_statement(tmpdir) -> None: # language=typescript jsx content = """ function funcA(a) { diff --git a/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py b/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py index 48bc5a502..ed5dc6a07 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py +++ b/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_export_aliased(tmpdir): +def test_export_aliased(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -31,7 +31,7 @@ def test_export_aliased(tmpdir): assert fuzz_export.resolved_symbol == file.get_function("fuzz") -def test_export_aliased_multiple(tmpdir): +def test_export_aliased_multiple(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -60,7 +60,7 @@ def test_export_aliased_multiple(tmpdir): assert baz_export.resolved_symbol == file.get_function("baz") -def test_export_aliased_default(tmpdir): +def test_export_aliased_default(tmpdir) -> None: # language=typescript content = """ function foo() {} diff --git a/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py b/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py index c9ae8a410..113a591ef 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py +++ b/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_export_export_statement(tmpdir): +def test_export_export_statement(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -29,7 +29,7 @@ def test_export_export_statement(tmpdir): ] -def test_remove_export(tmpdir): +def test_remove_export(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -55,7 +55,7 @@ def test_remove_export(tmpdir): ) -def test_remove_all_exports(tmpdir): +def test_remove_all_exports(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -77,7 +77,7 @@ def test_remove_all_exports(tmpdir): ) -def test_add_export(tmpdir): +def test_add_export(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -101,7 +101,7 @@ def test_add_export(tmpdir): ) -def test_insert_export_at_start(tmpdir): +def test_insert_export_at_start(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -125,7 +125,7 @@ def test_insert_export_at_start(tmpdir): ) -def test_remove_middle_export(tmpdir): +def test_remove_middle_export(tmpdir) -> None: # language=typescript content = """ function foo() {} @@ -150,7 +150,7 @@ def test_remove_middle_export(tmpdir): ) -def test_remove_inline_export(tmpdir): +def test_remove_inline_export(tmpdir) -> None: # language=typescript content = """ export function foo() {} @@ -172,7 +172,7 @@ def test_remove_inline_export(tmpdir): ) -def test_add_remove_reexport_inline(tmpdir): +def test_add_remove_reexport_inline(tmpdir) -> None: # language=typescript content = """ export { foo, bar } from './other'; @@ -198,7 +198,7 @@ def test_add_remove_reexport_inline(tmpdir): ) -def test_remove_namespace_export(tmpdir): +def test_remove_namespace_export(tmpdir) -> None: # language=typescript content = """ export namespace Foo { @@ -224,7 +224,7 @@ def test_remove_namespace_export(tmpdir): ) -def test_remove_add_wildcard_export(tmpdir): +def test_remove_add_wildcard_export(tmpdir) -> None: # language=typescript content = """ export * from './foo'; @@ -245,7 +245,7 @@ def test_remove_add_wildcard_export(tmpdir): ) -def test_remove_all_exports_multiline(tmpdir): +def test_remove_all_exports_multiline(tmpdir) -> None: # language=typescript content = """ function foo() {} diff --git a/tests/unit/codegen/sdk/typescript/export/test_external_export.py b/tests/unit/codegen/sdk/typescript/export/test_external_export.py index 56c169aeb..84e74d0ac 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_external_export.py +++ b/tests/unit/codegen/sdk/typescript/export/test_external_export.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_is_external_export_true(tmpdir): +def test_is_external_export_true(tmpdir) -> None: # language=typescript content = """ export { default as React } from "react"; @@ -22,7 +22,7 @@ def test_is_external_export_true(tmpdir): assert file.exports[0].is_external_export is True -def test_is_external_export_false(tmpdir): +def test_is_external_export_false(tmpdir) -> None: # language=typescript content = """ export { foo } from "./foo"; @@ -40,7 +40,7 @@ def test_is_external_export_false(tmpdir): assert file.exports[0].is_external_export is False -def test_multiple_external_exports(tmpdir): +def test_multiple_external_exports(tmpdir) -> None: # language=typescript content = """ export { default as React } from "react"; @@ -57,7 +57,7 @@ def test_multiple_external_exports(tmpdir): assert all(export.is_external_export for export in file.exports) -def test_mixed_internal_external_exports(tmpdir): +def test_mixed_internal_external_exports(tmpdir) -> None: # language=typescript content = """ export { default as lodash } from "lodash"; @@ -80,7 +80,7 @@ def test_mixed_internal_external_exports(tmpdir): assert file.exports[2].is_external_export is False -def test_nested_reexports(tmpdir): +def test_nested_reexports(tmpdir) -> None: # language=typescript with get_codebase_session( tmpdir=tmpdir, @@ -106,7 +106,7 @@ def test_nested_reexports(tmpdir): assert services_file.exports[0].is_external_export is False -def test_wildcard_exports(tmpdir): +def test_wildcard_exports(tmpdir) -> None: # language=typescript with get_codebase_session( tmpdir=tmpdir, diff --git a/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py b/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py index e035e2030..ecd60e762 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py +++ b/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_get_reexported_exports(tmpdir): +def test_get_reexported_exports(tmpdir) -> None: # language=typescript with get_codebase_session( tmpdir=tmpdir, @@ -42,7 +42,7 @@ def test_get_reexported_exports(tmpdir): assert len(reexports) == 0 -def test_get_reexported_export_with_external_module_on_export(tmpdir): +def test_get_reexported_export_with_external_module_on_export(tmpdir) -> None: # language=typescript with get_codebase_session( tmpdir=tmpdir, @@ -70,7 +70,7 @@ def test_get_reexported_export_with_external_module_on_export(tmpdir): assert len(reexports) == 2 -def test_get_reexported_export_with_alias(tmpdir): +def test_get_reexported_export_with_alias(tmpdir) -> None: # language=typescript with get_codebase_session( tmpdir=tmpdir, diff --git a/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py b/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py index fac383111..608ba5f88 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py +++ b/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_reduce_ternary_condition_to_true(tmpdir): +def test_reduce_ternary_condition_to_true(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -32,7 +32,7 @@ def test_reduce_ternary_condition_to_true(tmpdir): ) -def test_reduce_ternary_condition_to_false(tmpdir): +def test_reduce_ternary_condition_to_false(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -57,7 +57,7 @@ def test_reduce_ternary_condition_to_false(tmpdir): ) -def test_reduce_nested_ternary_condition_to_true_and_false(tmpdir): +def test_reduce_nested_ternary_condition_to_true_and_false(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -84,7 +84,7 @@ def test_reduce_nested_ternary_condition_to_true_and_false(tmpdir): ) -def test_reduce_nested_ternary_condition_outer_false(tmpdir): +def test_reduce_nested_ternary_condition_outer_false(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -109,7 +109,7 @@ def test_reduce_nested_ternary_condition_outer_false(tmpdir): ) -def test_reduce_multiple_ternary_conditions(tmpdir): +def test_reduce_multiple_ternary_conditions(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -138,7 +138,7 @@ def test_reduce_multiple_ternary_conditions(tmpdir): ) -def test_reduce_ternary_condition_with_function_call(tmpdir): +def test_reduce_ternary_condition_with_function_call(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -163,7 +163,7 @@ def test_reduce_ternary_condition_with_function_call(tmpdir): ) -def test_reduce_ternary_condition_with_dict(tmpdir): +def test_reduce_ternary_condition_with_dict(tmpdir) -> None: # language=typescript jsx # language=typescript content = """ @@ -198,7 +198,7 @@ def test_reduce_ternary_condition_with_dict(tmpdir): ) -def test_reduce_ternary_condition_with_dict_complex(tmpdir): +def test_reduce_ternary_condition_with_dict_complex(tmpdir) -> None: # language=typescript jsx # language=typescript content = """ @@ -234,7 +234,7 @@ def test_reduce_ternary_condition_with_dict_complex(tmpdir): ) -def test_reduce_ternary_condition_with_dict_trailing_comma(tmpdir): +def test_reduce_ternary_condition_with_dict_trailing_comma(tmpdir) -> None: # language=typescript content = """ function foo(): { a: number } { diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py b/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py index 9d4f26f75..4d862abfa 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py @@ -8,7 +8,7 @@ from codegen.sdk.typescript.file import TSFile -def test_binary_expressions(tmpdir): +def test_binary_expressions(tmpdir) -> None: # language=typescript content = """ let a: number = 1 + 2; @@ -127,7 +127,7 @@ def test_binary_expressions(tmpdir): assert file.get_global_var("v").value.operator.source == "in" -def test_chained_binary_expressions(tmpdir): +def test_chained_binary_expressions(tmpdir) -> None: # language=typescript content = """ // binary operators diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py b/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py index b21ef842b..a99a21bd7 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_reduce_binary_simple(tmpdir): +def test_reduce_binary_simple(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -33,7 +33,7 @@ def test_reduce_binary_simple(tmpdir): ) -def test_reduce_binary_object(tmpdir): +def test_reduce_binary_object(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -62,7 +62,7 @@ def test_reduce_binary_object(tmpdir): ) -def test_reduce_binary_complex_condition(tmpdir): +def test_reduce_binary_complex_condition(tmpdir) -> None: # language=typescript content = """ function bar(): void { @@ -91,7 +91,7 @@ def test_reduce_binary_complex_condition(tmpdir): ) -def test_reduce_negation_condition(tmpdir): +def test_reduce_negation_condition(tmpdir) -> None: # language=typescript content = """ function baz(): void { @@ -119,7 +119,7 @@ def test_reduce_negation_condition(tmpdir): ) -def test_reduce_jsx_element(tmpdir): +def test_reduce_jsx_element(tmpdir) -> None: # language=typescript jsx content = """ const MyComponent: React.FC = () => { @@ -154,7 +154,7 @@ def test_reduce_jsx_element(tmpdir): ) -def test_reduce_jsx_element_keep(tmpdir): +def test_reduce_jsx_element_keep(tmpdir) -> None: # language=typescript jsx content = """ const MyComponent: React.FC = () => { @@ -188,7 +188,7 @@ def test_reduce_jsx_element_keep(tmpdir): ) -def test_reduce_complex_condition_with_JSX(tmpdir): +def test_reduce_complex_condition_with_JSX(tmpdir) -> None: # language=typescript jsx content = """ const AnotherComponent: React.FC = () => { diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py b/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py index 7ce20bc67..5e2b5e668 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py @@ -5,7 +5,7 @@ from codegen.sdk.typescript.assignment import TSAssignment -def test_boolean_parse(tmpdir): +def test_boolean_parse(tmpdir) -> None: # language=typescript content = """ const a = true; diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_dict.py b/tests/unit/codegen/sdk/typescript/expressions/test_dict.py index 4478340dc..b9143da32 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_dict.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_dict.py @@ -9,7 +9,7 @@ from codegen.sdk.typescript.function import TSFunction -def test_dict_basic(tmpdir): +def test_dict_basic(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -36,7 +36,7 @@ def test_dict_basic(tmpdir): ) -def test_dict_multiline(tmpdir): +def test_dict_multiline(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -73,7 +73,7 @@ def test_dict_multiline(tmpdir): ) -def test_dict_insert(tmpdir): +def test_dict_insert(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -98,7 +98,7 @@ def test_dict_insert(tmpdir): @pytest.mark.parametrize("removes,inserts", cases, ids=[f"{removes=}-{inserts=}" for removes, inserts in cases]) -def test_dict_interleaved(tmpdir, removes, inserts): +def test_dict_interleaved(tmpdir, removes, inserts) -> None: ref_dict = {str(-1 + -i): -(i**2) for i in range(removes)} file = "test.ts" content = f""" @@ -124,7 +124,7 @@ def test_dict_interleaved(tmpdir, removes, inserts): @pytest.mark.parametrize("removes,inserts", cases, ids=[f"{removes=}-{inserts=}" for removes, inserts in cases]) -def test_dict_removes_first(tmpdir, removes, inserts): +def test_dict_removes_first(tmpdir, removes, inserts) -> None: ref_dict = {str(-1 + -i): -(i**2) for i in range(removes)} file = "test.ts" content = f""" @@ -149,7 +149,7 @@ def test_dict_removes_first(tmpdir, removes, inserts): @pytest.mark.parametrize("removes,inserts", cases, ids=[f"{removes=}-{inserts=}" for removes, inserts in cases]) -def test_dict_inserts_first(tmpdir, removes, inserts): +def test_dict_inserts_first(tmpdir, removes, inserts) -> None: ref_dict = {str(-1 + -i): -(i**2) for i in range(removes)} file = "test.ts" content = f""" @@ -174,7 +174,7 @@ def test_dict_inserts_first(tmpdir, removes, inserts): @pytest.mark.parametrize("existing,inserts", cases, ids=[f"{existing=}-{inserts=}" for existing, inserts in cases]) -def test_dict_append_existing(tmpdir, existing, inserts): +def test_dict_append_existing(tmpdir, existing, inserts) -> None: ref_dict = {str(-1 + -i): -(i**2) for i in range(existing)} file = "test.ts" content = f""" @@ -196,7 +196,7 @@ def test_dict_append_existing(tmpdir, existing, inserts): @pytest.mark.parametrize("existing", list(range(4)), ids=[f"existing={existing}" for existing in range(4)]) -def test_dict_set_existing(tmpdir, existing): +def test_dict_set_existing(tmpdir, existing) -> None: ref_dict = {str(-1 + -i): -(i**2) for i in range(existing)} file = "test.ts" content = f""" @@ -218,7 +218,7 @@ def test_dict_set_existing(tmpdir, existing): @pytest.mark.parametrize("existing,inserts", cases, ids=[f"existing={existing + 1}-{inserts=}" for existing, inserts in cases]) -def test_dict_set_existing_same(tmpdir, existing, inserts): +def test_dict_set_existing_same(tmpdir, existing, inserts) -> None: ref_dict = {str(-1 + -i): -(i**2) for i in range(existing)} file = "test.ts" content = f""" @@ -239,7 +239,7 @@ def test_dict_set_existing_same(tmpdir, existing, inserts): ) -def test_dict_empty(tmpdir): +def test_dict_empty(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -263,7 +263,7 @@ def test_dict_empty(tmpdir): ) -def test_dict_remove_insert(tmpdir): +def test_dict_remove_insert(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -286,7 +286,7 @@ def test_dict_remove_insert(tmpdir): ) -def test_dict_shorthand_remove_insert(tmpdir): +def test_dict_shorthand_remove_insert(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -309,7 +309,7 @@ def test_dict_shorthand_remove_insert(tmpdir): ) -def test_dict_edit(tmpdir): +def test_dict_edit(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -330,7 +330,7 @@ def test_dict_edit(tmpdir): ) -def test_dict_edit_shorthand(tmpdir): +def test_dict_edit_shorthand(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -351,7 +351,7 @@ def test_dict_edit_shorthand(tmpdir): ) -def test_dict_edit_not_shorthand(tmpdir): +def test_dict_edit_not_shorthand(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -372,7 +372,7 @@ def test_dict_edit_not_shorthand(tmpdir): ) -def test_dict_clear(tmpdir): +def test_dict_clear(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -394,7 +394,7 @@ def test_dict_clear(tmpdir): @pytest.mark.xfail(reason="Not implemented Yet") -def test_dict_obj(tmpdir): +def test_dict_obj(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -421,7 +421,7 @@ def test_dict_obj(tmpdir): ) -def test_dict_shorthand(tmpdir): +def test_dict_shorthand(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -448,7 +448,7 @@ def test_dict_shorthand(tmpdir): ) -def test_shorthand_multiline(tmpdir): +def test_shorthand_multiline(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -485,7 +485,7 @@ def test_shorthand_multiline(tmpdir): ) -def test_convert_shorthand(tmpdir): +def test_convert_shorthand(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -509,7 +509,7 @@ def test_convert_shorthand(tmpdir): ) -def test_dict_shorthand_insert(tmpdir): +def test_dict_shorthand_insert(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -530,7 +530,7 @@ def test_dict_shorthand_insert(tmpdir): ) -def test_dict_function_values(tmpdir): +def test_dict_function_values(tmpdir) -> None: # language=typescript content = """ export const mapper = { @@ -559,7 +559,7 @@ def test_dict_function_values(tmpdir): assert len(list(d.items())) == 3 assert list(d.keys()) == ["method1", "method2", "method3"] assert all(isinstance(v, TSFunction) for v in list(d.values())) - for key, func_def in d.items(): + for func_def in d.values(): func_def.insert_before("async ", newline=False, extended=False) func_def.set_return_type(f"Promise<{func_def.return_type.source}>") @@ -588,7 +588,7 @@ def test_dict_function_values(tmpdir): ) -def test_dict_usage(tmpdir): +def test_dict_usage(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -604,7 +604,7 @@ def test_dict_usage(tmpdir): assert {*foo.symbol_usages} == {obj} -def test_dict_usage_shorthand(tmpdir): +def test_dict_usage_shorthand(tmpdir) -> None: file = "test.ts" # language=typescript content = """ @@ -620,7 +620,7 @@ def test_dict_usage_shorthand(tmpdir): assert {*foo.symbol_usages} == {obj} -def test_dict_usage_spread(tmpdir): +def test_dict_usage_spread(tmpdir) -> None: file = "test.ts" # language=typescript jsx # language=typescript diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_expression.py b/tests/unit/codegen/sdk/typescript/expressions/test_expression.py index 3e66e8711..890a6c850 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_expression.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_expression.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_function_calls_from_function_call(tmpdir): +def test_function_calls_from_function_call(tmpdir) -> None: # language=typescript content = """ describe("LoadManager test", () => { @@ -19,7 +19,7 @@ def test_function_calls_from_function_call(tmpdir): assert len(func_call) == 6 -def test_remove_parenthesized(tmpdir): +def test_remove_parenthesized(tmpdir) -> None: # language=typescript content = """ const a = (b) || c; @@ -37,7 +37,7 @@ def test_remove_parenthesized(tmpdir): ) -def test_remove_tsx(tmpdir): +def test_remove_tsx(tmpdir) -> None: # language=typescript jsx content = """ const element =

Hello, {name}

; diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_number.py b/tests/unit/codegen/sdk/typescript/expressions/test_number.py index a191ff95b..82820eb99 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_number.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_number.py @@ -4,7 +4,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_number_parse(tmpdir): +def test_number_parse(tmpdir) -> None: # language=typescript content = """ const a = 1; diff --git a/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py b/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py index adaa00922..a8117fcbb 100644 --- a/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py +++ b/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py @@ -20,7 +20,7 @@ def _get_file(content: str): @pytest.fixture def export_check(ts_file): - def _export_check(*sources): + def _export_check(*sources) -> None: file = ts_file("\n".join(sources)) assert len(file.export_statements) == len(sources) for i, source in enumerate(sources): @@ -32,137 +32,137 @@ def _export_check(*sources): # 1. Named exports -def test_named_exports__export_const(export_check): +def test_named_exports__export_const(export_check) -> None: export_check("export const variable = value;") -def test_named_exports__export_let(export_check): +def test_named_exports__export_let(export_check) -> None: export_check("export let variable = value;") -def test_named_exports__export_var(export_check): +def test_named_exports__export_var(export_check) -> None: export_check("export var variable = value;") -def test_named_exports__export_function(export_check): +def test_named_exports__export_function(export_check) -> None: export_check("export function functionName() { /* ... */ }") -def test_named_exports__export_class(export_check): +def test_named_exports__export_class(export_check) -> None: export_check("export class ClassName { /* ... */ }") -def test_named_exports__export_interface(export_check): +def test_named_exports__export_interface(export_check) -> None: export_check("export interface InterfaceName { /* ... */ }") -def test_named_exports__export_type(export_check): +def test_named_exports__export_type(export_check) -> None: export_check("export type TypeName = value;") -def test_named_exports__export_enum(export_check): +def test_named_exports__export_enum(export_check) -> None: export_check("export enum EnumName { /* ... */ }") # 2. Default exports -def test_default_exports__export_default_value(export_check): +def test_default_exports__export_default_value(export_check) -> None: export_check("export default value;") -def test_default_exports__export_default_function(export_check): +def test_default_exports__export_default_function(export_check) -> None: export_check("export default function() { /* ... */ }") -def test_default_exports__export_default_class(export_check): +def test_default_exports__export_default_class(export_check) -> None: export_check("export default class { /* ... */ }") # 3. Exporting declarations after they're defined -def test_defined_declarations__just_export_statement(export_check): +def test_defined_declarations__just_export_statement(export_check) -> None: export_check("export { variable, functionName, ClassName };") # 4. Exporting with aliases -def test_exporting_with_aliases(export_check): +def test_exporting_with_aliases(export_check) -> None: export_check("export { variable as aliasName };") # 5. Re-exporting -def test_reexporting__export_many_names(export_check): +def test_reexporting__export_many_names(export_check) -> None: export_check("export { name1, name2 } from './other-module';") -def test_reexporting__export_many_names_with_aliases(export_check): +def test_reexporting__export_many_names_with_aliases(export_check) -> None: export_check("export { import1 as name1, import2 as name2 } from './other-module';") -def test_reexporting__export_star(export_check): +def test_reexporting__export_star(export_check) -> None: export_check("export * from './other-module';") -def test_reexporting__export_default(export_check): +def test_reexporting__export_default(export_check) -> None: export_check("export { default } from './other-module';") # 6. Combining default and named exports -def test_default_named__export_default_class(export_check): +def test_default_named__export_default_class(export_check) -> None: export_check("export default class { /* ... */ }") -def test_default_named__export_const(export_check): +def test_default_named__export_const(export_check) -> None: export_check("export const namedExport = value;") # 7. Exporting types -def test_types__export_type_block(export_check): +def test_types__export_type_block(export_check) -> None: export_check("export type { SomeType } from './types';") # 8. Exporting namespaces -def test_export_namespace(export_check): +def test_export_namespace(export_check) -> None: export_check("export namespace MyNamespace { export const something = value; }") # 9. Exporting as a namespace -def test_export_star_as_namespace(export_check): +def test_export_star_as_namespace(export_check) -> None: export_check("export * as myNamespace from './module';") # 10. Exporting declarations with modifiers -def test_declaration_with_modifiers__export_abstract_class(export_check): +def test_declaration_with_modifiers__export_abstract_class(export_check) -> None: export_check("export abstract class AbstractClass { /* ... */ }") -def test_declaration_with_modifiers__export_const_enum(export_check): +def test_declaration_with_modifiers__export_const_enum(export_check) -> None: export_check("export const enum ConstEnum { /* ... */ }") # 11. Exporting with generics -def test_generics__export_function(export_check): +def test_generics__export_function(export_check) -> None: export_check("export function genericFunction() { /* ... */ }") -def test_generics__export_class(export_check): +def test_generics__export_class(export_check) -> None: export_check("export class GenericClass { /* ... */ }") diff --git a/tests/unit/codegen/sdk/typescript/function/test_function_async.py b/tests/unit/codegen/sdk/typescript/function/test_function_async.py index 8383b911b..9ac41feaa 100644 --- a/tests/unit/codegen/sdk/typescript/function/test_function_async.py +++ b/tests/unit/codegen/sdk/typescript/function/test_function_async.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_function_is_async_basic(tmpdir): +def test_function_is_async_basic(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -66,7 +66,7 @@ class MyClass { ) -def test_function_is_async_extended(tmpdir): +def test_function_is_async_extended(tmpdir) -> None: # language=typescript content = """ /** Docstring */ @@ -146,7 +146,7 @@ class MyClass { ) -def test_function_is_async_other_syntax(tmpdir): +def test_function_is_async_other_syntax(tmpdir) -> None: # language=typescript content = """ // Arrow functions diff --git a/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py b/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py index 871518f3a..2e00b5687 100644 --- a/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py +++ b/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py @@ -13,7 +13,7 @@ from codegen.sdk.typescript.statements.assignment_statement import TSAssignmentStatement -def test_function_calls_from_file(tmpdir): +def test_function_calls_from_file(tmpdir) -> None: # language=typescript content = """ import { x, y, z } from './some_file'; @@ -59,7 +59,7 @@ def test_function_calls_from_file(tmpdir): ] -def test_function_calls_from_class(tmpdir): +def test_function_calls_from_class(tmpdir) -> None: # language=typescript content = """ import { bar } from './some_file'; @@ -100,7 +100,7 @@ class A { @pytest.mark.skip(reason="CG-9422 TS method decorator parsing needs to be fixed first") -def test_function_calls_from_decorated_definitions(tmpdir): +def test_function_calls_from_decorated_definitions(tmpdir) -> None: # language=typescript content = """ import { describe, it } from 'jest'; @@ -139,7 +139,7 @@ class A { @pytest.mark.xfail(reason="Broken by function call changes") -def test_function_calls_from_datatypes(tmpdir): +def test_function_calls_from_datatypes(tmpdir) -> None: # language=typescript content = """ function getConfig(): { max_retries: number; timeout: number } { @@ -178,7 +178,7 @@ def test_function_calls_from_datatypes(tmpdir): ] -def test_function_calls_from_function_parameters(tmpdir): +def test_function_calls_from_function_parameters(tmpdir) -> None: # language=typescript content = """ // function parameters @@ -200,7 +200,7 @@ def test_function_calls_from_function_parameters(tmpdir): ] -def test_function_calls_from_while_loop(tmpdir): +def test_function_calls_from_while_loop(tmpdir) -> None: # language=typescript content = """ // while loop conditions @@ -222,7 +222,7 @@ def test_function_calls_from_while_loop(tmpdir): assert file.function_calls[1].parent.statement_type == StatementType.EXPRESSION_STATEMENT -def test_function_calls_from_if_conditions(tmpdir): +def test_function_calls_from_if_conditions(tmpdir) -> None: # language=typescript content = """ // if conditions @@ -247,7 +247,7 @@ def test_function_calls_from_if_conditions(tmpdir): ] -def test_function_calls_for_nested_calls(tmpdir): +def test_function_calls_for_nested_calls(tmpdir) -> None: # language=typescript content = """ parent(nested()) @@ -265,7 +265,7 @@ def test_function_calls_for_nested_calls(tmpdir): ] -def test_function_calls_for_chained_calls(tmpdir): +def test_function_calls_for_chained_calls(tmpdir) -> None: # language=typescript content = """ parent().child().grandchild() @@ -287,7 +287,7 @@ def test_function_calls_for_chained_calls(tmpdir): assert fcalls[2].parent.parent == fcalls[1] -def test_function_calls_in_function_call(tmpdir): +def test_function_calls_in_function_call(tmpdir) -> None: # language=typescript content = """ describe("top level", () => { diff --git a/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py b/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py index 13b2100bf..8ed0e838f 100644 --- a/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py +++ b/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_convert_simple_props_to_interface(tmpdir): +def test_convert_simple_props_to_interface(tmpdir) -> None: # language=typescript content = """ function Button(props: { @@ -40,7 +40,7 @@ def test_convert_simple_props_to_interface(tmpdir): ) -def test_convert_props_to_interface_with_complex_types(tmpdir): +def test_convert_props_to_interface_with_complex_types(tmpdir) -> None: # language=typescript content = """ function DataGrid(props: { @@ -75,7 +75,7 @@ def test_convert_props_to_interface_with_complex_types(tmpdir): ) -def test_convert_props_to_interface_with_generics(tmpdir): +def test_convert_props_to_interface_with_generics(tmpdir) -> None: # language=typescript content = """ function List(props: { @@ -111,7 +111,7 @@ def test_convert_props_to_interface_with_generics(tmpdir): ) -def test_convert_props_to_interface_with_extends(tmpdir): +def test_convert_props_to_interface_with_extends(tmpdir) -> None: # language=typescript content = """ function CustomButton(props: { diff --git a/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py b/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py index 33527dab5..773accab5 100644 --- a/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py +++ b/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_ts_import_is_dynamic_in_function_declaration(tmpdir): +def test_ts_import_is_dynamic_in_function_declaration(tmpdir) -> None: # language=typescript content = """ import { staticImport } from './static'; @@ -21,7 +21,7 @@ def test_ts_import_is_dynamic_in_function_declaration(tmpdir): assert imports[1].is_dynamic # dynamic import in function -def test_ts_import_is_dynamic_in_method_definition(tmpdir): +def test_ts_import_is_dynamic_in_method_definition(tmpdir) -> None: # language=typescript content = """ import { Component } from '@angular/core'; @@ -46,7 +46,7 @@ class MyComponent { assert imports[2].is_dynamic # dynamic import in decorated method -def test_ts_import_is_dynamic_in_arrow_function(tmpdir): +def test_ts_import_is_dynamic_in_arrow_function(tmpdir) -> None: # language=typescript content = """ import { useState } from 'react'; @@ -67,7 +67,7 @@ def test_ts_import_is_dynamic_in_arrow_function(tmpdir): assert imports[1].is_dynamic # dynamic import in async arrow function -def test_ts_import_is_dynamic_in_if_statement(tmpdir): +def test_ts_import_is_dynamic_in_if_statement(tmpdir) -> None: # language=typescript content = """ import { isFeatureEnabled } from './utils'; @@ -91,7 +91,7 @@ def test_ts_import_is_dynamic_in_if_statement(tmpdir): assert imports[2].is_dynamic # dynamic import in else block -def test_ts_import_is_dynamic_in_try_statement(tmpdir): +def test_ts_import_is_dynamic_in_try_statement(tmpdir) -> None: # language=typescript content = """ import { logger } from './logger'; @@ -112,7 +112,7 @@ def test_ts_import_is_dynamic_in_try_statement(tmpdir): assert imports[1].is_dynamic # dynamic import in try block -def test_ts_import_is_dynamic_in_catch_clause(tmpdir): +def test_ts_import_is_dynamic_in_catch_clause(tmpdir) -> None: # language=typescript content = """ import { logger } from './logger'; @@ -132,7 +132,7 @@ def test_ts_import_is_dynamic_in_catch_clause(tmpdir): assert imports[1].is_dynamic # dynamic import in catch block -def test_ts_import_is_dynamic_in_finally_clause(tmpdir): +def test_ts_import_is_dynamic_in_finally_clause(tmpdir) -> None: # language=typescript content = """ import { logger } from './logger'; @@ -154,7 +154,7 @@ def test_ts_import_is_dynamic_in_finally_clause(tmpdir): assert imports[1].is_dynamic # dynamic import in finally block -def test_ts_import_is_dynamic_in_while_statement(tmpdir): +def test_ts_import_is_dynamic_in_while_statement(tmpdir) -> None: # language=typescript content = """ import { condition } from './utils'; @@ -172,7 +172,7 @@ def test_ts_import_is_dynamic_in_while_statement(tmpdir): assert imports[1].is_dynamic # dynamic import in while loop -def test_ts_import_is_dynamic_in_for_statement(tmpdir): +def test_ts_import_is_dynamic_in_for_statement(tmpdir) -> None: # language=typescript content = """ import { items } from './data'; @@ -190,7 +190,7 @@ def test_ts_import_is_dynamic_in_for_statement(tmpdir): assert imports[1].is_dynamic # dynamic import in for loop -def test_ts_import_is_dynamic_in_do_statement(tmpdir): +def test_ts_import_is_dynamic_in_do_statement(tmpdir) -> None: # language=typescript content = """ import { shouldContinue } from './utils'; @@ -208,7 +208,7 @@ def test_ts_import_is_dynamic_in_do_statement(tmpdir): assert imports[1].is_dynamic # dynamic import in do-while loop -def test_ts_import_is_dynamic_in_switch_statement(tmpdir): +def test_ts_import_is_dynamic_in_switch_statement(tmpdir) -> None: # language=typescript content = """ import { getFeatureFlag } from './utils'; diff --git a/tests/unit/codegen/sdk/typescript/react/test_interface_props.py b/tests/unit/codegen/sdk/typescript/react/test_interface_props.py index 8afaa33c3..8011f97f9 100644 --- a/tests/unit/codegen/sdk/typescript/react/test_interface_props.py +++ b/tests/unit/codegen/sdk/typescript/react/test_interface_props.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_convert_props_to_interface_with_proptypes_oneof(tmpdir): +def test_convert_props_to_interface_with_proptypes_oneof(tmpdir) -> None: # language=typescript content = """ import { PropTypes } from 'react'; @@ -53,7 +53,7 @@ def test_convert_props_to_interface_with_proptypes_oneof(tmpdir): ) -def test_convert_class_props_to_interface_with_proptypes_oneof(tmpdir): +def test_convert_class_props_to_interface_with_proptypes_oneof(tmpdir) -> None: # language=typescript content = """ import { PropTypes } from 'react'; @@ -103,7 +103,7 @@ class Component extends React.Component { ) -def test_convert_simple_function_props_to_interface(tmpdir): +def test_convert_simple_function_props_to_interface(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -140,7 +140,7 @@ def test_convert_simple_function_props_to_interface(tmpdir): ) -def test_convert_complex_function_props_to_interface(tmpdir): +def test_convert_complex_function_props_to_interface(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -210,7 +210,7 @@ def test_convert_complex_function_props_to_interface(tmpdir): ) -def test_convert_simple_class_props_to_interface(tmpdir): +def test_convert_simple_class_props_to_interface(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -255,7 +255,7 @@ class Component extends React.Component { ) -def test_convert_function_props_with_inferred_parameters_to_interface(tmpdir): +def test_convert_function_props_with_inferred_parameters_to_interface(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -316,7 +316,7 @@ def test_convert_function_props_with_inferred_parameters_to_interface(tmpdir): ) -def test_convert_class_props_with_inferred_parameters_to_interface(tmpdir): +def test_convert_class_props_with_inferred_parameters_to_interface(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -383,7 +383,7 @@ class Component extends React.Component { ) -def test_convert_props_to_interface_with_any_params(tmpdir): +def test_convert_props_to_interface_with_any_params(tmpdir) -> None: # language=typescript content = """ import { PropTypes } from 'react'; @@ -420,7 +420,7 @@ def test_convert_props_to_interface_with_any_params(tmpdir): ) -def test_convert_class_props_to_interface_with_any_params(tmpdir): +def test_convert_class_props_to_interface_with_any_params(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -465,7 +465,7 @@ class Component extends React.Component { ) -def test_convert_complex_class_props_to_interface(tmpdir): +def test_convert_complex_class_props_to_interface(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from "react"; @@ -549,7 +549,7 @@ class Component extends React.Component { ) -def test_convert_props_to_interface_with_nested_structures(tmpdir): +def test_convert_props_to_interface_with_nested_structures(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -636,7 +636,7 @@ def test_convert_props_to_interface_with_nested_structures(tmpdir): ) -def test_convert_class_props_to_interface_with_nested_structures(tmpdir): +def test_convert_class_props_to_interface_with_nested_structures(tmpdir) -> None: # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -737,7 +737,7 @@ class OtherComponent extends React.Component { ) -def test_convert_props_to_interface_with_proptypes_node_and_element(tmpdir): +def test_convert_props_to_interface_with_proptypes_node_and_element(tmpdir) -> None: # language=typescript content = """ import { PropTypes } from 'react'; diff --git a/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py b/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py index dc4f975a1..b5284739f 100644 --- a/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py +++ b/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_declassify_class_component(tmpdir): +def test_declassify_class_component(tmpdir) -> None: # language=typescript content = """ import React from "react"; diff --git a/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py b/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py index 8cc9b1ee7..102cd8055 100644 --- a/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py +++ b/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py @@ -10,7 +10,7 @@ from codegen.sdk.typescript.file import TSFile -def test_reduce_condition_to_true_elif(tmpdir): +def test_reduce_condition_to_true_elif(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -46,7 +46,7 @@ def test_reduce_condition_to_true_elif(tmpdir): ) -def test_reduce_condition_to_false_elif(tmpdir): +def test_reduce_condition_to_false_elif(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -80,7 +80,7 @@ def test_reduce_condition_to_false_elif(tmpdir): ) -def test_reduce_condition_to_true_else(tmpdir): +def test_reduce_condition_to_true_else(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -109,7 +109,7 @@ def test_reduce_condition_to_true_else(tmpdir): ) -def test_reduce_condition_to_false_else(tmpdir): +def test_reduce_condition_to_false_else(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -138,7 +138,7 @@ def test_reduce_condition_to_false_else(tmpdir): ) -def test_reduce_condition_multiple_if_blocks(tmpdir): +def test_reduce_condition_multiple_if_blocks(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -176,7 +176,7 @@ def test_reduce_condition_multiple_if_blocks(tmpdir): ) -def test_reduce_condition_nested_if(tmpdir): +def test_reduce_condition_nested_if(tmpdir) -> None: # language=typescript content = """ class MyClass { @@ -228,7 +228,7 @@ class MyClass { ) -def test_reduce_condition_else_if_to_true(tmpdir): +def test_reduce_condition_else_if_to_true(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -269,7 +269,7 @@ def test_reduce_condition_else_if_to_true(tmpdir): ) -def test_reduce_condition_else_if_to_false(tmpdir): +def test_reduce_condition_else_if_to_false(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -307,7 +307,7 @@ def test_reduce_condition_else_if_to_false(tmpdir): ) -def test_reduce_condition_else_statement_raises(tmpdir): +def test_reduce_condition_else_statement_raises(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -328,7 +328,7 @@ def test_reduce_condition_else_statement_raises(tmpdir): else_block.reduce_condition(True) -def test_reduce_condition_to_true_single_if(tmpdir): +def test_reduce_condition_to_true_single_if(tmpdir) -> None: # language=typescript content = """ function foo(): void { @@ -355,7 +355,7 @@ def test_reduce_condition_to_true_single_if(tmpdir): ) -def test_reduce_condition_to_false_single_if(tmpdir): +def test_reduce_condition_to_false_single_if(tmpdir) -> None: # language=typescript content = """ function foo(): void { diff --git a/tests/unit/codegen/shared/compilation/test_codeblock_validation.py b/tests/unit/codegen/shared/compilation/test_codeblock_validation.py index 0f69ad463..af0e8593e 100644 --- a/tests/unit/codegen/shared/compilation/test_codeblock_validation.py +++ b/tests/unit/codegen/shared/compilation/test_codeblock_validation.py @@ -4,7 +4,7 @@ from codegen.shared.exceptions.compilation import DangerousUserCodeException -def test_no_dangerous_operations(): +def test_no_dangerous_operations() -> None: codeblock = """ print("not dangerous") """ @@ -14,7 +14,7 @@ def test_no_dangerous_operations(): pytest.fail("Unexpected DangerousPythonCodeError raised") -def test_dangerous_operations(): +def test_dangerous_operations() -> None: codeblock = """ print(os.environ["ENV"]) """ diff --git a/tests/unit/codegen/shared/compilation/test_function_compilation.py b/tests/unit/codegen/shared/compilation/test_function_compilation.py index da6ccf44a..7c786cc5b 100644 --- a/tests/unit/codegen/shared/compilation/test_function_compilation.py +++ b/tests/unit/codegen/shared/compilation/test_function_compilation.py @@ -4,7 +4,7 @@ from codegen.shared.exceptions.compilation import InvalidUserCodeException -def test_valid_func_str_should_not_raise(): +def test_valid_func_str_should_not_raise() -> None: func_str = """ from codegen.sdk.core.codebase import Codebase @@ -17,7 +17,7 @@ def execute(codebase: Codebase): pytest.fail("Unexpected InvalidUserCodeException raised") -def test_valid_func_str_with_nested_should_not_raise(): +def test_valid_func_str_with_nested_should_not_raise() -> None: func_str = """ from codegen.sdk.core.codebase import Codebase @@ -33,7 +33,7 @@ def nested(): pytest.fail("Unexpected InvalidUserCodeException raised") -def test_compile_syntax_error_indent_error_raises(): +def test_compile_syntax_error_indent_error_raises() -> None: func_str = """ def execute(codebase: Codebase): a = 1 @@ -47,7 +47,7 @@ def execute(codebase: Codebase): assert "> 3: a = 1" in error_msg -def test_compile_syntax_error_raises(): +def test_compile_syntax_error_raises() -> None: func_str = """ def execute(codebase: Codebase): print "syntax error" @@ -61,7 +61,7 @@ def execute(codebase: Codebase): assert '> 3: print "syntax error"' in error_msg -def test_compile_non_syntax_error_unicode_error_raises(): +def test_compile_non_syntax_error_unicode_error_raises() -> None: func_str = """ def execute(codebase: Codebase): print("hello")\udcff @@ -78,7 +78,7 @@ def execute(codebase: Codebase): assert "'utf-8' codec can't encode character '\\udcff'" in error_msg -def test_exec_error_non_syntax_error_zero_division_raises(): +def test_exec_error_non_syntax_error_zero_division_raises() -> None: """This is to test that we're handling errors (ex: ZeroDivisionError) that are raised during `exec` properly. NOTE: this case wouldn't happen with an actual func_str from create_function_str_from_codeblock b/c the func_str would just take in a codebase. @@ -95,7 +95,7 @@ def execute(codebase: Codebase, exec_error: int = 1/0): assert "> 2: def execute(codebase: Codebase, exec_error: int = 1/0):" in error_msg -def test_exec_error_non_syntax_error_name_error_raises(): +def test_exec_error_non_syntax_error_name_error_raises() -> None: """This is to test that we're handling errors (ex: NameError) that are raised during `exec` properly. NOTE: this case wouldn't happen with an actual func_str from create_function_str_from_codeblock b/c the func_str would not have any patches. @@ -113,7 +113,7 @@ def execute(codebase: Codebase): assert '> 2: @patch("foo", return_value="bar")' in error_msg -def test_func_str_uses_custom_scope_var_does_not_raise(): +def test_func_str_uses_custom_scope_var_does_not_raise() -> None: """This tests if a func_str references a var that is included in custom scope, it will not raise a NameError. This is to test the case when a group of codemods is run and a later one relies on a local defined in a previous one. """ diff --git a/tests/unit/codegen/shared/compilation/test_function_construction.py b/tests/unit/codegen/shared/compilation/test_function_construction.py index 1ba1fe6c9..a3bfc55ab 100644 --- a/tests/unit/codegen/shared/compilation/test_function_construction.py +++ b/tests/unit/codegen/shared/compilation/test_function_construction.py @@ -3,7 +3,7 @@ from codegen.shared.compilation.function_construction import create_function_str_from_codeblock -def test_no_execute_func_wraps(): +def test_no_execute_func_wraps() -> None: codeblock = """ print(len(codebase.files)) """ @@ -18,7 +18,7 @@ def execute(codebase: Codebase, pr_options: PROptions | None = None, pr = None, ) -def test_func_name_already_exists(): +def test_func_name_already_exists() -> None: codeblock = """ def execute(codebase: Codebase): print(len(codebase.files)) @@ -27,7 +27,7 @@ def execute(codebase: Codebase): assert codeblock in func -def test_func_name_not_execute(): +def test_func_name_not_execute() -> None: codeblock = """ print(len(codebase.files)) """ @@ -42,7 +42,7 @@ def not_execute(codebase: Codebase, pr_options: PROptions | None = None, pr = No ) -def test_function_str_includes_imports(): +def test_function_str_includes_imports() -> None: codeblock = """ print(len(codebase.files)) """ diff --git a/tests/unit/codegen/shared/compilation/test_string_to_code.py b/tests/unit/codegen/shared/compilation/test_string_to_code.py index 7d71ab50e..cc92d0a66 100644 --- a/tests/unit/codegen/shared/compilation/test_string_to_code.py +++ b/tests/unit/codegen/shared/compilation/test_string_to_code.py @@ -8,7 +8,7 @@ from codegen.shared.exceptions.control_flow import StopCodemodException -def test_syntax_error_raises(): +def test_syntax_error_raises() -> None: codeblock = """ print "syntax error" """ @@ -20,7 +20,7 @@ def test_syntax_error_raises(): assert 'print "syntax error"' in error_msg -def test_print_os_environ_raises(): +def test_print_os_environ_raises() -> None: codeblock = """ print(os.environ["ENV"]) """ @@ -28,7 +28,7 @@ def test_print_os_environ_raises(): create_execute_function_from_codeblock(codeblock=codeblock) -def test_print_calls_codebase_log(): +def test_print_calls_codebase_log() -> None: """Test print is monkey patched to call codebase.log""" codeblock = """ print("actually codebase.log") @@ -40,7 +40,7 @@ def test_print_calls_codebase_log(): assert mock_log.call_args_list[0][0][0] == "actually codebase.log" -def test_set_custom_scope_does_not_raise(): +def test_set_custom_scope_does_not_raise() -> None: """Test if the custom scope is set and the codeblock uses a var defined in the scope, it does not raise a NameError.""" codeblock = """ print(local_a) @@ -53,7 +53,7 @@ def test_set_custom_scope_does_not_raise(): @patch("codegen.shared.compilation.string_to_code.logger") -def test_stop_codemod_execution_logs_and_raises(mock_logger): +def test_stop_codemod_execution_logs_and_raises(mock_logger) -> None: codeblock = """ local_a = "this is local_a" raise StopCodemodException("test exception") @@ -65,7 +65,7 @@ def test_stop_codemod_execution_logs_and_raises(mock_logger): mock_logger.info.call_args_list[1][0][0] == "Stopping codemod due to StopCodemodException: test exception" -def test_references_import_from_generated_imports_does_not_raise(): +def test_references_import_from_generated_imports_does_not_raise() -> None: codeblock = """ print(os.getcwd()) # test external import print(MessageType.GITHUB) # test gs private import @@ -77,7 +77,7 @@ def test_references_import_from_generated_imports_does_not_raise(): assert mock_log.call_count == 3 -def test_references_import_not_in_generated_imports_raises_runtime_error(): +def test_references_import_not_in_generated_imports_raises_runtime_error() -> None: codeblock = """ print(Chainable.__name__) """ @@ -90,7 +90,7 @@ def test_references_import_not_in_generated_imports_raises_runtime_error(): assert "> 1: print(Chainable.__name__)" in error_msg -def test_error_during_execution_raises_runtime_error(): +def test_error_during_execution_raises_runtime_error() -> None: codeblock = """ print(var_that_does_not_exist) """ @@ -105,7 +105,7 @@ def test_error_during_execution_raises_runtime_error(): @pytest.mark.xfail(reason="TODO(CG-9581): fix codeblocks with return statements") -def test_return_statement_still_returns_locals(): +def test_return_statement_still_returns_locals() -> None: """Test if there is a return statement in a customer code block, the function should still return the locals""" codeblock = """ local_a = "this is local_a" diff --git a/tests/unit/codemods/test_codemod.py b/tests/unit/codemods/test_codemod.py index a9e7b1949..6d00a026d 100644 --- a/tests/unit/codemods/test_codemod.py +++ b/tests/unit/codemods/test_codemod.py @@ -2,8 +2,8 @@ from codemods.codemod import Codemod -def test_codemod_execute(): - def sample_execute(codebase: Codebase): +def test_codemod_execute() -> None: + def sample_execute(codebase: Codebase) -> None: for file in codebase.files: file.content = "print('hello')" diff --git a/tests/unit/skills/implementations/ai_skills.py b/tests/unit/skills/implementations/ai_skills.py index 16829b5df..87f236511 100644 --- a/tests/unit/skills/implementations/ai_skills.py +++ b/tests/unit/skills/implementations/ai_skills.py @@ -25,7 +25,7 @@ class RefactorClass(Skill, ABC): @staticmethod @skill_impl(test_cases=[RefactorClassPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: my_class = codebase.get_symbol("MyClass", optional=True) if my_class is None: msg = "MyClass not found in codebase" @@ -49,7 +49,7 @@ class GenerateDocstrings(Skill, ABC): @staticmethod @skill_impl(test_cases=[GenerateDocstringsPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: for cls in codebase.classes: for method in cls.methods: new_docstring = codebase.ai( @@ -73,7 +73,7 @@ class WriteTest(Skill, ABC): @staticmethod @skill_impl(test_cases=[WriteTestPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: my_function = codebase.get_function("my_function", optional=True) if my_function is None: msg = "my_function not found in codebase" @@ -100,7 +100,7 @@ class RenameMethods(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameMethodsPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: for cls in codebase.classes: for method in cls.methods: new_name = codebase.ai(f"Create a better name for the method {method.name}.", target=method) diff --git a/tests/unit/skills/implementations/asyncify_skills.py b/tests/unit/skills/implementations/asyncify_skills.py index d6640adae..66c3bd65d 100644 --- a/tests/unit/skills/implementations/asyncify_skills.py +++ b/tests/unit/skills/implementations/asyncify_skills.py @@ -133,7 +133,7 @@ class AsyncifyFunctionSkill(Skill): """ @staticmethod - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: pass @staticmethod @@ -158,7 +158,7 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: @staticmethod @skill_impl([SkillTestCase(files=ts_files)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: func_to_convert = codebase.get_function("funcToConvert") convert_queue = deque([func_to_convert]) diff --git a/tests/unit/skills/implementations/code_block_skills.py b/tests/unit/skills/implementations/code_block_skills.py index 1001bb7bb..bcdb07b68 100644 --- a/tests/unit/skills/implementations/code_block_skills.py +++ b/tests/unit/skills/implementations/code_block_skills.py @@ -85,7 +85,7 @@ class UnwrapFunctionBody(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_input, output=py_output_unwrap_function)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Unwraps the body of all functions in the file""" # iterate through all functions in the codebase for function in codebase.functions: @@ -94,7 +94,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCaseTSFile(input=ts_input, output=ts_output_unwrap_function)])], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Unwraps the body of all functions in the file""" # iterate through all functions in the codebase for function in codebase.functions: @@ -145,7 +145,7 @@ class UnwrapIfStatement(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_input, output=py_output_unwrap_if_statement)])], language=ProgrammingLanguage.PYTHON) @skill_impl([SkillTestCase(files=[SkillTestCaseTSFile(input=ts_input, output=ts_output_unwrap_if_statement)])], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: for file in codebase.files: for if_block in file.code_block.if_blocks: if_block.consequence_block.unwrap() @@ -174,7 +174,7 @@ class UnwrapWithStatement(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_input, output=py_output_unwrap_with_statement)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Unwraps the body of all with statements in the file""" # for all functions in the codebase for function in codebase.functions: @@ -185,7 +185,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """With Statements are not supported in TypeScript""" ... @@ -377,7 +377,7 @@ class ConvertStatementToArgument(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_convert_test_assertion_input, output=py_convert_test_assertion_output)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Transform test assertion statements into an argument to test functions that make a call to a http method.""" methods = ["post", "get", "put", "delete", "patch"] client_name = "client" @@ -415,7 +415,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCaseTSFile(input=ts_convert_test_assertion_input, output=ts_convert_test_assertion_output)])], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Transform test assertion statements into an argument to test functions that make a call to a http method.""" methods = ["post", "get", "put", "delete", "patch"] client_name = "client" diff --git a/tests/unit/skills/implementations/comment_skills.py b/tests/unit/skills/implementations/comment_skills.py index 917662a27..07e03492e 100644 --- a/tests/unit/skills/implementations/comment_skills.py +++ b/tests/unit/skills/implementations/comment_skills.py @@ -52,7 +52,7 @@ class EslintCommentSkill(Skill): @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: ESLINT_RULE = "@typescript-eslint/no-explicit-any" # Iterate over all files in the codebase diff --git a/tests/unit/skills/implementations/decorator_skills.py b/tests/unit/skills/implementations/decorator_skills.py index 549101580..7874c2847 100644 --- a/tests/unit/skills/implementations/decorator_skills.py +++ b/tests/unit/skills/implementations/decorator_skills.py @@ -44,7 +44,7 @@ class AddDecoratorToFunction(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Adds a decorator to each function or method in the codebase if they do not already have it.""" # get the decorator symbol decorator_symbol = codebase.get_symbol("my_decorator") @@ -72,7 +72,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """TODO: Implement this method @Rishi Desai""" ... @@ -134,7 +134,7 @@ class UpdateDocStringOfDecoratedMethods(Skill, ABC): language=ProgrammingLanguage.PYTHON, prompt="Update the docstring of class methods if it has a decarators containing `with_user` in its name by appending 'OPERATES ON USER DATA'.", ) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: for cls in codebase.classes: for method in cls.methods: if method.decorators and any(["with_user" in dec.name for dec in method.decorators]): @@ -146,7 +146,7 @@ def python_skill_func(codebase: CodebaseType): language=ProgrammingLanguage.TYPESCRIPT, prompt="Update the docstring of class methods if it has a decarators containing `withUser` in its name by appending 'OPERATES ON USER DATA'.", ) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: for cls in codebase.classes: for method in cls.methods: if method.decorators and any(["withUser" in dec.name for dec in method.decorators]): diff --git a/tests/unit/skills/implementations/eval_skills.py b/tests/unit/skills/implementations/eval_skills.py index 7e4a6b38e..f20922257 100644 --- a/tests/unit/skills/implementations/eval_skills.py +++ b/tests/unit/skills/implementations/eval_skills.py @@ -25,7 +25,7 @@ class AddCopyrightHeaderSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_1")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: r"""Adds the following header to all files in the codebase: 'Copyright (c) Codegen.\nAll rights reserved.\n\n'""" for file in codebase.files: # Adds header to the file. Note: comments are added @@ -33,7 +33,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_1")], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: r"""Adds the following header to all files in the codebase: '// Copyright (c) Codegen.\n// All rights reserved.\n\n'""" for file in codebase.files: # Adds header to the file. Note: comments are added @@ -46,7 +46,7 @@ class MoveFooFunctionsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_2")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Move all functions starting with 'foo' to foo.py.""" # get the foo.py file if it exists, otherwise create it Note: extension is included in the file name foo_file = codebase.get_file("foo.py") if codebase.has_file("foo.py") else codebase.create_file("foo.py") @@ -60,7 +60,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not Implemented""" ... @@ -71,7 +71,7 @@ class AddDecoratorToFooFunctionsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_3")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Adds the following decorator to all functions starting with 'foo': '@decorator_function'.""" # get the decorator_function symbol decorator_symbol = codebase.get_symbol("decorator_function") @@ -90,7 +90,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not Implemented""" ... @@ -101,7 +101,7 @@ class RenameFooToBarSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_4")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Renames all functions starting with 'foo' to start with 'bar'.""" # for each function in the codebase for function in codebase.functions: @@ -112,7 +112,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not Implemented""" # for each function in the codebase for function in codebase.functions: @@ -128,7 +128,7 @@ class AddReturnTypeHintSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_5")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Adds an int return type hint to all functions starting with 'foo'.""" # for each function in the codebase for function in codebase.functions: @@ -139,7 +139,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not Implemented""" ... @@ -158,7 +158,7 @@ class MoveEnumsToSeparateFileSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_7")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Moves any enums within a file into a file called: `enums.py`. Creates the `enums.py` if it does not exist. If the original file only contains enums this skill renames it to `enums.py` """ @@ -188,7 +188,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not Implemented""" ... @@ -199,13 +199,13 @@ class UpdateOptionalTypeHintsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_8")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Replaces Optional[type] with type | None in all functions.""" # pattern to match Optional[type] optional_type_pattern = re.compile(r"Optional\[(.*?)]") # update optional parameter type hints - def update_optional_parameter_type_hints(function: PyFunction): + def update_optional_parameter_type_hints(function: PyFunction) -> None: # for each parameter in the function for parameter in function.parameters: # if the parameter is typed @@ -219,7 +219,7 @@ def update_optional_parameter_type_hints(function: PyFunction): # update the parameter type hint parameter.set_type_annotation(new_type) - def update_optional_return_type_hints(function: PyFunction): + def update_optional_return_type_hints(function: PyFunction) -> None: # if the function has a return type if function.return_type: # get the old return type @@ -249,7 +249,7 @@ def update_optional_return_type_hints(function: PyFunction): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not Implemented""" ... @@ -265,7 +265,7 @@ class DeleteUnusedSymbolsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_3")], language=ProgrammingLanguage.TYPESCRIPT) @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_6")], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # for each symbol in the codebase for symbol in codebase.symbols: # if the symbol has no usages @@ -290,7 +290,7 @@ class MarkInternalFunctionsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_7")], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Marks all functions that are only used in the `app` directory as an internal function. Marks functions as internal by adding the @internal tag to the bottom of the docstring. """ @@ -325,7 +325,7 @@ def typescript_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Not implemented for Python""" ... @@ -343,7 +343,7 @@ class MoveNonDefaultExportedJSXComponentsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_2")], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Moves all JSX components that are not exported by default into a new file that is in the same directory as the original file.""" # for each file in the codebase for file in codebase.files: @@ -376,6 +376,6 @@ def typescript_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Not implemented for Python""" ... diff --git a/tests/unit/skills/implementations/example_skills.py b/tests/unit/skills/implementations/example_skills.py index 1951a4419..b48f7475b 100644 --- a/tests/unit/skills/implementations/example_skills.py +++ b/tests/unit/skills/implementations/example_skills.py @@ -22,7 +22,7 @@ class SetGlobalVarValueSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Set the value of all global variables to 2 if their current assigned literal is 1""" for file in codebase.files: for v in file.global_vars: @@ -31,7 +31,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... @@ -48,7 +48,7 @@ class RenameGlobalVarSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Rename all global variables named 'x' to 'y'.""" for file in codebase.files: for v in file.global_vars: @@ -57,7 +57,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... @@ -136,7 +136,7 @@ class SkipAllTests(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Adds pytest.mark.skip decorator to all test functions with reason="This is a test".""" for file in codebase.files: for function in file.functions: @@ -152,7 +152,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... @@ -173,7 +173,7 @@ class AddTypeHintsSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Adds type hints to function parameters and return values.""" for function in codebase.functions: if not function.return_type: @@ -195,7 +195,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" """Adds type hints to function parameters and return values.""" for function in codebase.functions: @@ -241,7 +241,7 @@ class RenameClassSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Rename the class OldName => NewName""" old_name = "OldName" new_name = "NewName" @@ -252,7 +252,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... @@ -311,7 +311,7 @@ class AddWrapperFunctionSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Add a trivial wrapper function called `new_{function.name}` around each function and class method that just calls the original function.""" for file in codebase.files: for function in file.functions: @@ -327,7 +327,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... @@ -363,7 +363,7 @@ class RemoveUnusedImportsSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Removes unused import statements from the code.""" for file in codebase.files: for imp in file.imports: @@ -372,7 +372,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... @@ -406,7 +406,7 @@ class AddDocstringsSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Adds docstrings to all functions and methods.""" for file in codebase.files: for function in file.functions: @@ -416,6 +416,6 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Not implemented for TypeScript""" ... diff --git a/tests/unit/skills/implementations/export_skills.py b/tests/unit/skills/implementations/export_skills.py index a30fea49c..92f4d1625 100644 --- a/tests/unit/skills/implementations/export_skills.py +++ b/tests/unit/skills/implementations/export_skills.py @@ -63,7 +63,7 @@ class ExportSkills(Skill): @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: """Convert default exports to named exports in TypeScript""" for file in codebase.files: for export in file.exports: diff --git a/tests/unit/skills/implementations/expressions/dict.py b/tests/unit/skills/implementations/expressions/dict.py index f8e38bbbb..59e88f5ba 100644 --- a/tests/unit/skills/implementations/expressions/dict.py +++ b/tests/unit/skills/implementations/expressions/dict.py @@ -18,7 +18,7 @@ class DictToSchema(Skill): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType): + def python_skill_func(codebase: PyCodebaseType) -> None: """Converts a dictionary into a Schema object. Converts the key value pairs into arguments for the constructor""" # iterate over all global vars for v in codebase.global_vars: diff --git a/tests/unit/skills/implementations/expressions/list.py b/tests/unit/skills/implementations/expressions/list.py index 8852e6a92..adfa66965 100644 --- a/tests/unit/skills/implementations/expressions/list.py +++ b/tests/unit/skills/implementations/expressions/list.py @@ -27,7 +27,7 @@ class AppendToGlobalList(Skill, ABC): @staticmethod @skill_impl(test_cases_append_py, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases_append_ts, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: """Append 2 to the global list variable 'a' in Python.""" a = codebase.get_symbol("a") a.value.append("2") @@ -58,7 +58,7 @@ class RemoveFromGlobalList(Skill, ABC): @staticmethod @skill_impl(test_cases_remove_py, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases_remove_ts, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: """Remove 2 from the global list variable 'a'""" a = codebase.get_symbol("a", optional=True) assert a, "Symbol 'a' not found" @@ -87,7 +87,7 @@ class ClearGlobalList(Skill, ABC): @staticmethod @skill_impl(test_cases_clear_py, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases_clear_ts, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: """Clear the global list variable 'a'""" a = codebase.get_symbol("a") a.value.clear() diff --git a/tests/unit/skills/implementations/expressions/type.py b/tests/unit/skills/implementations/expressions/type.py index fb9eecd67..3eb1cca75 100644 --- a/tests/unit/skills/implementations/expressions/type.py +++ b/tests/unit/skills/implementations/expressions/type.py @@ -30,7 +30,7 @@ class AppendTypeToUnionTypeSkill(Skill): @staticmethod @skill_impl(test_cases_append_py, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """If the type of 'a' is a UnionType, append "str" to it if it doesn't already exist""" a: PyAssignment = codebase.get_symbol("a") if isinstance(a.type, UnionType): @@ -39,7 +39,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases_append_ts, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """If the type of 'a' is a UnionType, append "str" to it if it doesn't already exist""" a: TSAssignment = codebase.get_symbol("a") if isinstance(a.type, UnionType): @@ -73,7 +73,7 @@ class ConvertToBuiltInTypeSkill(Skill): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=built_in_type_input, output=built_in_type_output)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: """Replaces type annotations using typing module with builtin types.""" import_replacements = {"List": "list", "Dict": "dict", "Set": "set", "Tuple": "tuple"} @@ -92,6 +92,6 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl([], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """The typing package is only available in Python""" ... diff --git a/tests/unit/skills/implementations/feature_flag_deletion_skill.py b/tests/unit/skills/implementations/feature_flag_deletion_skill.py index 17744025f..303d13693 100644 --- a/tests/unit/skills/implementations/feature_flag_deletion_skill.py +++ b/tests/unit/skills/implementations/feature_flag_deletion_skill.py @@ -101,7 +101,7 @@ class DeleteRolledOutFeatureFlagSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=py_files)], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType): + def python_skill_func(codebase: PyCodebaseType) -> None: """Implements the feature flag deletion for Python codebases.""" feature_flag = codebase.get_symbol("ROLLED_OUT_FLAG_TO_DELETE") feature_flag_name = feature_flag.name @@ -123,7 +123,7 @@ def python_skill_func(codebase: PyCodebaseType): @staticmethod @skill_impl([SkillTestCase(files=ts_files)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: """Implements the feature flag deletion for TypeScript codebases.""" feature_flag = codebase.get_symbol("ROLLED_OUT_FLAG_TO_DELETE") feature_flag_name = feature_flag.name diff --git a/tests/unit/skills/implementations/function_skills.py b/tests/unit/skills/implementations/function_skills.py index 0168af72a..22403bde0 100644 --- a/tests/unit/skills/implementations/function_skills.py +++ b/tests/unit/skills/implementations/function_skills.py @@ -55,14 +55,14 @@ class AppendParameterSkill(Skill, ABC): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType): + def python_skill_func(codebase: PyCodebaseType) -> None: """Append a parameter to the function signature in Python""" foo = codebase.get_symbol("foo") foo.parameters.append("b: int") @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: """Append a parameter to the function signature in TypeScript""" foo = codebase.get_symbol("foo") foo.parameters.append("b: number") diff --git a/tests/unit/skills/implementations/global_var_skills.py b/tests/unit/skills/implementations/global_var_skills.py index bf38f9873..b89fa154e 100644 --- a/tests/unit/skills/implementations/global_var_skills.py +++ b/tests/unit/skills/implementations/global_var_skills.py @@ -92,7 +92,7 @@ class DeleteUnusedLoggerSkill(Skill, ABC): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType): + def python_skill_func(codebase: PyCodebaseType) -> None: """Remove all global variables that are defined as `logger = get_logger(__name__)` if they are unused""" for file in codebase.files: for var in file.global_vars: @@ -101,7 +101,7 @@ def python_skill_func(codebase: PyCodebaseType): @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: """Remove all global variables that are defined as `logger = getLogger()` if they are unused""" for file in codebase.files: for var in file.global_vars: diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py b/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py index 4d4a4c11e..8af8bc793 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py @@ -29,7 +29,7 @@ class FileAppImportGraph(Skill, ABC): @staticmethod @skill_impl(test_cases=[FileAppImportGraphTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: import networkx as nx # Create a directed graph diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py b/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py index 21bbd1a6f..059ad37c3 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py @@ -61,7 +61,7 @@ class CallGraphFromNode(Skill, ABC): @staticmethod @skill_impl(test_cases=[CallGraphFromNodeTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Create a directed graph G = nx.DiGraph() @@ -71,7 +71,7 @@ def skill_func(codebase: CodebaseType): # ===== [ Maximum Recursive Depth ] ===== MAX_DEPTH = 5 - def create_downstream_call_trace(parent: FunctionCall | Function | None = None, depth: int = 0): + def create_downstream_call_trace(parent: FunctionCall | Function | None = None, depth: int = 0) -> None: """Creates call graph for parent This function recurses through the call graph of a function and creates a visualization @@ -194,7 +194,7 @@ class CallGraphFilter(Skill, ABC): @staticmethod @skill_impl(test_cases=[CallGraphFilterTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Create a directed graph G = nx.DiGraph() @@ -212,7 +212,7 @@ def skill_func(codebase: CodebaseType): cls = codebase.get_class("MyClass") # Define a recursive function to traverse function calls - def create_filtered_downstream_call_trace(parent: FunctionCall | Function, current_depth, max_depth): + def create_filtered_downstream_call_trace(parent: FunctionCall | Function, current_depth, max_depth) -> None: if current_depth > max_depth: return @@ -289,7 +289,7 @@ class CallPathsBetweenNodes(Skill, ABC): @staticmethod @skill_impl(test_cases=[CallPathsBetweenNodesTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Create a directed graph G = nx.DiGraph() @@ -297,7 +297,7 @@ def skill_func(codebase: CodebaseType): MAX_DEPTH = 5 # Define a recursive function to traverse usages - def create_downstream_call_trace(parent: FunctionCall | Function, end: Callable, current_depth, max_depth): + def create_downstream_call_trace(parent: FunctionCall | Function, end: Callable, current_depth, max_depth) -> None: if current_depth > max_depth: return diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py b/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py index 27b8ed1c3..5a6ed69b4 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py @@ -111,7 +111,7 @@ class DeadCode(Skill, ABC): @staticmethod @skill_impl(test_cases=[PyDeadCodeTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Create a directed graph to visualize dead and second-order dead code G = nx.DiGraph() diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py b/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py index b5fec176b..d87674fb0 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py @@ -85,7 +85,7 @@ class RepoDirTree(Skill, ABC): @staticmethod @skill_impl(test_cases=[PyRepoDirTreeTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Create a directed graph G = nx.DiGraph() diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py b/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py index 608487257..e57fc8f08 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py @@ -97,7 +97,7 @@ class ForeignKeyGraph(Skill, ABC): @staticmethod @skill_impl(test_cases=[PyForeignKeyGraphTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Create a mapping dictionary to hold relationships foreign_key_mapping = {} diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py b/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py index ce61479ec..b349a45a4 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py @@ -87,7 +87,7 @@ class ImportCycleDetectionAndVisualization(Skill, ABC): @staticmethod @skill_impl(test_cases=[ImportCycleDetectionAndVisualizationTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: G: DiGraph = networkx.DiGraph() # iterate over all imports diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py b/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py index e8f6eb3b4..6a250516c 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py @@ -71,7 +71,7 @@ class CountLargeFiles(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountLargeFilesPyTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CountLargeFilesTSTest], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: file_to_lines = {} for file in codebase.files: file_to_lines[file.filepath] = file.end_point[0] diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py b/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py index a16dbe70c..f7d909229 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py @@ -69,7 +69,7 @@ class AutoDocstringGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[AutoDocstringGeneratorTest], skip_test=True, language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: functions_without_docstring = 0 # Iterate over all functions in the codebase for function in codebase.functions: diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py b/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py index a918c0ac7..ac3f92254 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py @@ -83,7 +83,7 @@ class CountUnnamedKeywordArguments(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUnnamedKeywordArgumentsTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: unnamed_kwargs_count = 0 # Iterate through all files in the codebase diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py index b728735bc..95d954e82 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py @@ -120,7 +120,7 @@ class CountUntypedAttributesInCodebase(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUntypedAttributesInCodebasePyTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CountUntypedAttributesInCodebaseTSTest], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: untyped_attributes_count = 0 typed_attributes_count = 0 diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py index b179f7599..8b20fd185 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py @@ -76,7 +76,7 @@ class CountUntypedParameters(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUntypedParametersTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: untitled_parameters_count = 0 # Iterate through all files in the codebase diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py index 82b492792..11187956c 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py @@ -50,7 +50,7 @@ class CountUntypedReturnStatements(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUntypedReturnStatementsTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: untitled_return_count = 0 # Iterate through all files in the codebase diff --git a/tests/unit/skills/implementations/guides/codebase-ai.py b/tests/unit/skills/implementations/guides/codebase-ai.py index 4140257bc..251070d33 100644 --- a/tests/unit/skills/implementations/guides/codebase-ai.py +++ b/tests/unit/skills/implementations/guides/codebase-ai.py @@ -44,7 +44,7 @@ class MethodSummaryGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[MethodSummaryGeneratorPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # get the method and its parent class method: Function = codebase.get_class("MyClass").get_method("target_method") parent_class = method.parent @@ -150,7 +150,7 @@ class FunctionDecomposition(Skill, ABC): @staticmethod @skill_impl(test_cases=[FunctionDecompositionPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Get the large function large_function = codebase.get_function("large_function") @@ -194,7 +194,7 @@ class DocstringGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[DocstringGeneratorPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Loop through all functions in the codebase for function in codebase.functions: # Generate a new docstring for the function @@ -237,7 +237,7 @@ class DocstringFormatter(Skill, ABC): @staticmethod @skill_impl(test_cases=[DocstringFormatterPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Loop through all functions in the codebase for function in codebase.functions: # Convert the docstring to the new format diff --git a/tests/unit/skills/implementations/guides/complex-renaming.py b/tests/unit/skills/implementations/guides/complex-renaming.py index b3694b2aa..4c2970119 100644 --- a/tests/unit/skills/implementations/guides/complex-renaming.py +++ b/tests/unit/skills/implementations/guides/complex-renaming.py @@ -66,7 +66,7 @@ class RenameFunctionAndUpdateReferences(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Find the symbol to rename old_function = codebase.get_file("path/to/file.py").get_function("old_function_name") @@ -75,7 +75,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Find the symbol to rename old_function = codebase.get_file("path/to/file.ts").get_function("old_function_name") @@ -99,7 +99,7 @@ class AutoRenameFunction(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: function = codebase.get_file("path/to/file.py").get_function("old_function_name") function.rename("new_function_name") @@ -110,7 +110,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: function = codebase.get_file("path/to/file.ts").get_function("old_function_name") function.rename("new_function_name") @@ -189,7 +189,7 @@ class AutomaticClassRenamingWithReferenceUpdate(Skill, ABC): @staticmethod @skill_impl(test_cases=[AutoRenameClassPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[AutoRenameClassTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: old_class = codebase.get_class("OldClassName") old_class.rename("NewClassName") @@ -277,7 +277,7 @@ class RemoveDeprecatedPrefixfromFunctions(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveDeprecatedPrefixfromFunctionsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveDeprecatedPrefixfromFunctionsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate over all codebase functions for function in codebase.functions: # Filter for functions starting with deprecated_ @@ -398,7 +398,7 @@ class RenameMethodInBaseAndSubclasses(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameMethodPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RenameMethodTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: base_class = codebase.get_class("BaseClass") old_method = base_class.get_method("old_method") diff --git a/tests/unit/skills/implementations/guides/creating-documentation.py b/tests/unit/skills/implementations/guides/creating-documentation.py index c7fa4cf3e..08a458f45 100644 --- a/tests/unit/skills/implementations/guides/creating-documentation.py +++ b/tests/unit/skills/implementations/guides/creating-documentation.py @@ -57,7 +57,7 @@ class UpdateFunctionDocstring(Skill, ABC): @staticmethod @skill_impl(test_cases=[UpdateFunctionDocstringPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Get a specific function function = codebase.get_file("path/to/file.py").get_function("my_function") # Update its docstring @@ -65,7 +65,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[UpdateFunctionDocstringTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Get a specific function function = codebase.get_file("path/to/file.ts").get_function("myFunction") # Update its docstring @@ -157,7 +157,7 @@ class CalculateDocumentationCoverage(Skill, ABC): @staticmethod @skill_impl(test_cases=[CalculateDocumentationCoveragePyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CalculateDocumentationCoverageTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Initialize counters for total and documented functions/classes count_total = 0 count_documented = 0 @@ -230,7 +230,7 @@ class DocstringEnhancer(Skill, ABC): @staticmethod @skill_impl(test_cases=[DocstringEnhancerPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[DocstringEnhancerTSTestCase], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: for function in codebase.functions: current_docstring = function.docstring if current_docstring: @@ -363,7 +363,7 @@ class StaticDocstringGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[StaticDocstringGeneratorPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[StaticDocstringGeneratorTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate through all functions in the codebase for function in codebase.functions: # Check if the function has a docstring diff --git a/tests/unit/skills/implementations/guides/deleting-dead-code.py b/tests/unit/skills/implementations/guides/deleting-dead-code.py index c6f7a99c4..67a1bc47a 100644 --- a/tests/unit/skills/implementations/guides/deleting-dead-code.py +++ b/tests/unit/skills/implementations/guides/deleting-dead-code.py @@ -122,7 +122,7 @@ class RemoveUnusedSymbols(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedSymbolsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedSymbolsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate through all symbols in the codebase for symbol in codebase.symbols: # Check if the symbols has no usages @@ -195,7 +195,7 @@ class RemoveUnusedFunctions(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedFunctionsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedFunctionsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate through all functions in the codebase for function in codebase.functions: # Check if the function has no usages and no call sites @@ -262,7 +262,7 @@ class RemoveUnusedImports(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedImportsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedImportsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate through all imports in the codebase for import_stmt in codebase.imports: # Check if the import statement has no usages @@ -335,7 +335,7 @@ class RemoveUnusedLocalVariableAssignments(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedLocalVariableAssignmentsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedLocalVariableAssignmentsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate through all functions in the codebase for func in codebase.functions: # Iterate through local variable assignments in the function @@ -407,7 +407,7 @@ class RemoveUnusedParametersAndArguments(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedParametersAndArgumentsPyTestCase], language=ProgrammingLanguage.PYTHON, ignore=True) @skill_impl(test_cases=[RemoveUnusedParametersAndArgumentsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # iterate through all functions in the codebase for function in codebase.functions: for param in function.parameters: @@ -492,7 +492,7 @@ class RemoveUnusedClasses(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedClassesPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedClassesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Iterate through all classes in the codebase for cls in codebase.classes: # Check if the class has no usages @@ -582,7 +582,7 @@ class CleanUpCodebase(Skill, ABC): @staticmethod @skill_impl(test_cases=[CleanUpCodebasePyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CleanUpCodebaseTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # iterate through all files in the codebase for file in codebase.files: # Check if the file is empty diff --git a/tests/unit/skills/implementations/guides/increase-type-coverage.py b/tests/unit/skills/implementations/guides/increase-type-coverage.py index 52bf3a854..04e1c8f22 100644 --- a/tests/unit/skills/implementations/guides/increase-type-coverage.py +++ b/tests/unit/skills/implementations/guides/increase-type-coverage.py @@ -76,7 +76,7 @@ class CountTypedParametersSkill(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountTypedParametersPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CountTypedParametersTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Initialize counters for total parameters and typed parameters total_parameters = 0 typed_parameters = 0 @@ -200,7 +200,7 @@ class SetReturnTypeToNoneForFunctionsWithoutReturns(Skill, ABC): @staticmethod @skill_impl(test_cases=[SetReturnTypeToNoneForFunctionsWithoutReturnsPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Iterate through all files in the codebase for file in codebase.files: # Check if 'app' is in the file's filepath @@ -214,7 +214,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[SetReturnTypeToNoneForFunctionsWithoutReturnsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Iterate through all files in the codebase for file in codebase.files: # Check if 'app' is in the file's filepath @@ -310,7 +310,7 @@ class ModifyReturnTypeSkill(Skill, ABC): @staticmethod @skill_impl(test_cases=[ModifyReturnTypeSkillPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify target_file = codebase.get_file("path/to/file.py") function = target_file.get_function("function_name") @@ -325,7 +325,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[ModifyReturnTypeSkillTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify target_file = codebase.get_file("path/to/file.ts") function = target_file.get_function("functionName") @@ -378,7 +378,7 @@ class ModifyReturnTypeWithNewParameter(Skill, ABC): @staticmethod @skill_impl(test_cases=[ModifyReturnTypeWithNewParameterTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify function = codebase.get_file("path/to/file.py").get_function("function_name") # def function_name() -> tuple[a, b]: ... @@ -419,7 +419,7 @@ class InspectFunctionReturnType(Skill, ABC): @staticmethod @skill_impl(test_cases=[InspectFunctionReturnTypePyTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Find the symbol to inspect function = codebase.get_file("path/to/file.py").get_function("function_name") # def function_name() -> tuple[a, b]: ... @@ -533,7 +533,7 @@ class InspectResolveFunctionReturnType(Skill, ABC): @staticmethod @skill_impl(test_cases=[InspectResolveFunctionReturnTypePySanityTest], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Find the symbol to inspect function = codebase.get_file("path/to/file.py").get_function("function_name") # from xyz import MyContainer, a, b @@ -544,7 +544,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[InspectResolveFunctionReturnTypeTSSanityTest], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Find the symbol to inspect function = codebase.get_file("path/to/file.ts").get_function("functionName") # import { MyContainer, a, b } './types' @@ -595,7 +595,7 @@ class ResolveAndRenameGlobalVariableType(Skill, ABC): @staticmethod @skill_impl(test_cases=[ResolveAndRenameGlobalVariableTypeTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: a = codebase.get_file("path/to/file.py").get_global_var("a") # a: MyType = ... print(a.type) # Resolves to MyType diff --git a/tests/unit/skills/implementations/guides/manipulating-collections.py b/tests/unit/skills/implementations/guides/manipulating-collections.py index d95c24bd7..0d68f8cce 100644 --- a/tests/unit/skills/implementations/guides/manipulating-collections.py +++ b/tests/unit/skills/implementations/guides/manipulating-collections.py @@ -54,7 +54,7 @@ class AddParameterToFunction(Skill, ABC): @staticmethod @skill_impl(test_cases=[AddParameterToFunctionPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify function = codebase.get_file("path/to/file.py").get_function("function_name") @@ -63,7 +63,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[AddParameterToFunctionTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify function = codebase.get_file("path/to/file.ts").get_function("functionName") @@ -116,7 +116,7 @@ class ModifyDictionaryValue(Skill, ABC): @staticmethod @skill_impl(test_cases=[ModifyDictionaryValuePyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # var = {"example_key": "example_value"} # Find the symbol to modify var = codebase.get_file("path/to/file.py").get_global_var("foo") @@ -134,7 +134,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[ModifyDictionaryValueTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # var = {"example_key": "example_value"} # Find the symbol to modify var = codebase.get_file("path/to/file.ts").get_global_var("foo") @@ -182,7 +182,7 @@ class ConvertVariableToSchema(Skill, ABC): @staticmethod @skill_impl(test_cases=[ConvertVariableToSchemaPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify var = codebase.get_file("path/to/file.py").get_global_var("var_name") @@ -232,7 +232,7 @@ class AppendToGlobalVariableList(Skill, ABC): @staticmethod @skill_impl(test_cases=[AppendToGlobalVariableListPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify var = codebase.get_file("path/to/file.py").get_global_var("foo") @@ -246,7 +246,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[AppendToGlobalVariableListTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify var = codebase.get_file("path/to/file.ts").get_global_var("foo") @@ -292,7 +292,7 @@ class CheckFunctionDecoratorPresence(Skill, ABC): @staticmethod @skill_impl(test_cases=[CheckFunctionDecoratorPresencePyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Find the symbol to modify function = codebase.get_file("path/to/file.py").get_function("function_name") diff --git a/tests/unit/skills/implementations/guides/organize-your-codebase.py b/tests/unit/skills/implementations/guides/organize-your-codebase.py index b78330b51..d9e9eb79e 100644 --- a/tests/unit/skills/implementations/guides/organize-your-codebase.py +++ b/tests/unit/skills/implementations/guides/organize-your-codebase.py @@ -67,7 +67,7 @@ class SplitFunctionsIntoSeparateFiles(Skill, ABC): @staticmethod @skill_impl(test_cases=[SplitFunctionsIntoSeparateFilesPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Retrieve the Python file from the codebase file = codebase.get_file("path/to/file.py") # Iterate through the functions in the file @@ -147,7 +147,7 @@ class MoveSymbolDemonstration(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolDemonstrationPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: source_file = codebase.get_file("path/to/source_file.py") # =====[ Code Snippet ]===== # Get the symbol @@ -159,7 +159,7 @@ def python_skill_func(codebase: CodebaseType): @staticmethod @skill_impl(test_cases=[MoveSymbolDemonstrationTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: source_file = codebase.get_file("path/to/source_file.ts") # =====[ Code Snippet ]===== # Get the symbol @@ -247,7 +247,7 @@ class MoveSymbolWithUpdatedImports(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolWithUpdatedImportsPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType): + def python_skill_func(codebase: CodebaseType) -> None: symbol_to_move = codebase.get_symbol("symbol_to_move") dst_file = codebase.create_file("new_file.py") symbol_to_move.move_to_file(dst_file, strategy="update_all_imports") @@ -337,7 +337,7 @@ class MoveSymbolWithAddBackEdgeStrategy(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolWithAddBackEdgeStrategyPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: symbol_to_move = codebase.get_symbol("symbol_to_move") dst_file = codebase.create_file("new_file.py") symbol_to_move.move_to_file(dst_file, strategy="add_back_edge") @@ -447,14 +447,14 @@ class MoveSymbolToFileWithDependencies(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolToFileWithDependenciesPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: my_symbol = codebase.get_symbol("my_symbol") dst_file = codebase.create_file("new_file.py") my_symbol.move_to_file(dst_file, include_dependencies=True) @staticmethod @skill_impl(test_cases=[MoveSymbolToFileWithDependenciesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: my_symbol = codebase.get_symbol("mySymbol") dst_file = codebase.create_file("new_file.ts") my_symbol.move_to_file(dst_file, include_dependencies=True) @@ -526,7 +526,7 @@ class MoveSymbolsWithDependencies(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolsWithDependenciesPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: # Retrieve the source and destination files source_file = codebase.get_file("path/to/source_file.py") dest_file = codebase.get_file("path/to/destination_file.py") diff --git a/tests/unit/skills/implementations/if_statement_skills.py b/tests/unit/skills/implementations/if_statement_skills.py index aeb3b1991..33317ae28 100644 --- a/tests/unit/skills/implementations/if_statement_skills.py +++ b/tests/unit/skills/implementations/if_statement_skills.py @@ -93,7 +93,7 @@ class ReduceIfStatementConditionSkill(Skill, ABC): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType): + def python_skill_func(codebase: PyCodebaseType) -> None: """Simplifies the if/else control flow by reducing conditions that are `condition_to_set` to True""" for file in codebase.files: for function in file.functions: @@ -106,7 +106,7 @@ def python_skill_func(codebase: PyCodebaseType): @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: """Simplifies the if/else control flow by reducing conditions that are `conditionToSet` to True""" for file in codebase.files: for function in file.functions: diff --git a/tests/unit/skills/implementations/move_symbols_skills.py b/tests/unit/skills/implementations/move_symbols_skills.py index a68b48eec..c6c182d1a 100644 --- a/tests/unit/skills/implementations/move_symbols_skills.py +++ b/tests/unit/skills/implementations/move_symbols_skills.py @@ -61,7 +61,7 @@ class MoveDataclassesSkills(Skill): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType): + def python_skill_func(codebase: PyCodebaseType) -> None: """Moves the dataclasses and adds a back edge to the moved symbol in the original file""" # Iterate over all files in the codebase for file in codebase.files: @@ -85,6 +85,6 @@ def python_skill_func(codebase: PyCodebaseType): @staticmethod @skill_impl([], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def typescript_skill_func(codebase: CodebaseType): + def typescript_skill_func(codebase: CodebaseType) -> None: """Dataclasses is only available in Python""" ... diff --git a/tests/unit/skills/implementations/type_inheritance_skills.py b/tests/unit/skills/implementations/type_inheritance_skills.py index e6c3f54df..90057b306 100644 --- a/tests/unit/skills/implementations/type_inheritance_skills.py +++ b/tests/unit/skills/implementations/type_inheritance_skills.py @@ -224,12 +224,12 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: pass @staticmethod - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: pass @staticmethod @skill_impl([SkillTestCase(files=ts_files_readonly)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: """Given a type alias 'MyMapper', find all inherited or extended implementations of the type object. Loops through all codebase symbols and handles each symbol type accordingly. """ @@ -270,12 +270,12 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: pass @staticmethod - def skill_func(codebase: CodebaseType): + def skill_func(codebase: CodebaseType) -> None: pass @staticmethod @skill_impl([SkillTestCase(files=ts_files_write)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType): + def typescript_skill_func(codebase: TSCodebaseType) -> None: FUNC_NAME_TO_CONVERT = "convert" mapper_symbol: TypeAlias = codebase.get_symbol("MyMapper") @@ -331,7 +331,4 @@ def typescript_skill_func(codebase: TSCodebaseType): processed.add(f) if not f.is_async: f.asyncify() - - for call_site in f.call_sites: - if call_site.parent and isinstance(call_site.parent, Function): - funcs_to_asyncify.append(call_site.parent) + funcs_to_asyncify.extend(call_site.parent for call_site in f.call_sites if call_site.parent and isinstance(call_site.parent, Function)) diff --git a/tests/unit/skills/test_skills.py b/tests/unit/skills/test_skills.py index 11d83baca..f0c04e08a 100644 --- a/tests/unit/skills/test_skills.py +++ b/tests/unit/skills/test_skills.py @@ -13,7 +13,7 @@ # @pytest.pytestmark.skip(reason="AI skill testing") @pytest.mark.parametrize("skill, test_case", [(skill, case) for skill, case, _ in cases], ids=[skill.name + f"-{skill.language.name}-case-{case.name or idx}" for skill, case, idx in cases]) -def test_all_example_skills(tmpdir, skill: SkillImplementation, test_case: SkillTestCase, snapshot): +def test_all_example_skills(tmpdir, skill: SkillImplementation, test_case: SkillTestCase, snapshot) -> None: with get_codebase_session(tmpdir=tmpdir, programming_language=skill.language, files=test_case.to_input_dict(), repo_config=BaseRepoConfig(), verify_output=False, verify_input=False) as codebase: skill._skill_func(codebase) codebase.commit() From 62123ce45be13d602c7c6a9fa11f5cb4651162fa Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 11:07:41 -0800 Subject: [PATCH 03/12] undo update tests --- .../git/clients/test_github_client_factory.py | 4 +- .../test_remote_repo_operator.py | 6 +-- tests/integration/codegen/test_imports.py | 4 +- tests/integration/codemod/test_diffs.py | 2 +- .../codemod/codebase_comparison_utils.py | 2 +- tests/shared/codemod/commands.py | 14 ++--- .../shared/codemod/verified_codemod_utils.py | 2 +- tests/shared/mocks/mock_ai_helper.py | 2 +- tests/shared/skills/decorators.py | 2 +- tests/shared/skills/skill.py | 2 +- tests/shared/skills/skill_implementation.py | 4 +- tests/shared/skills/utils.py | 4 +- tests/shared/utils/recursion.py | 2 +- tests/unit/codegen/cli/test_reset.py | 12 ++--- .../git/clients/test_git_repo_client.py | 6 +-- tests/unit/codegen/git/schemas/test_github.py | 2 +- tests/unit/codegen/gscli/test_cli.py | 2 +- .../codegen/runner/sandbox/test_executor.py | 16 +++--- .../codegen/runner/sandbox/test_runner.py | 10 ++-- .../codegen/runner/utils/test_branch_name.py | 4 +- .../benchmark/codebase/test_codebase_reset.py | 6 +-- .../test_codemod_writer_decorators.py | 2 +- .../codebase_graph/test_codebase_reset.py | 28 +++++----- .../test_symbol_parent_statement.py | 8 +-- .../sdk/codebase/flagging/test_code_flag.py | 2 +- .../sdk/codebase/flagging/test_group_all.py | 2 +- .../test_transaction_mangager_checks.py | 8 +-- .../codebase/test_codebase_raise_error.py | 2 +- .../sdk/python/codebase/test_control_flow.py | 16 +++--- .../code_block/test_code_block_indent.py | 14 ++--- .../code_block/test_code_block_insert.py | 18 +++---- .../code_block/test_code_block_remove.py | 10 ++-- .../code_block/test_code_block_unwrap.py | 8 +-- .../code_block/test_code_block_wrap.py | 4 +- .../test_function_calls_from_symbol.py | 18 +++---- .../expressions/test_binary_expression.py | 14 ++--- .../test_binary_reduce_condition.py | 10 ++-- .../sdk/python/expressions/test_boolean.py | 2 +- .../sdk/python/expressions/test_number.py | 2 +- .../sdk/python/expressions/test_type.py | 8 +-- .../python/function/test_function_async.py | 4 +- .../import_resolution/test_is_dynamic.py | 22 ++++---- .../test_if_block_reduce_block.py | 26 ++++----- .../test_with_statement_properties.py | 10 ++-- .../code_block/test_code_block_indent.py | 14 ++--- .../code_block/test_code_block_unwrap.py | 8 +-- .../code_block/test_code_block_wrap.py | 2 +- .../typescript/export/test_export_aliased.py | 6 +-- .../export/test_export_export_statement.py | 22 ++++---- .../typescript/export/test_external_export.py | 12 ++--- .../export/test_get_reexported_exports.py | 6 +-- .../test_ternary_reduce_condition.py | 18 +++---- .../expressions/test_binary_expression.py | 4 +- .../test_binary_reduce_condition.py | 14 ++--- .../typescript/expressions/test_boolean.py | 2 +- .../sdk/typescript/expressions/test_dict.py | 52 +++++++++--------- .../typescript/expressions/test_expression.py | 6 +-- .../sdk/typescript/expressions/test_number.py | 2 +- .../file/test_file_export_statements.py | 54 +++++++++---------- .../function/test_function_async.py | 6 +-- .../test_function_calls_from_symbol.py | 20 +++---- .../test_function_parameter_to_interface.py | 8 +-- .../import_resolution/test_is_dynamic.py | 22 ++++---- .../typescript/react/test_interface_props.py | 26 ++++----- .../typescript/react/test_ts_declassify.py | 2 +- .../test_if_block_reduce_block.py | 22 ++++---- .../compilation/test_codeblock_validation.py | 4 +- .../compilation/test_function_compilation.py | 16 +++--- .../compilation/test_function_construction.py | 8 +-- .../shared/compilation/test_string_to_code.py | 18 +++---- tests/unit/codemods/test_codemod.py | 4 +- .../unit/skills/implementations/ai_skills.py | 8 +-- .../skills/implementations/asyncify_skills.py | 4 +- .../implementations/code_block_skills.py | 14 ++--- .../skills/implementations/comment_skills.py | 2 +- .../implementations/decorator_skills.py | 8 +-- .../skills/implementations/eval_skills.py | 42 +++++++-------- .../skills/implementations/example_skills.py | 32 +++++------ .../skills/implementations/export_skills.py | 2 +- .../implementations/expressions/dict.py | 2 +- .../implementations/expressions/list.py | 6 +-- .../implementations/expressions/type.py | 8 +-- .../feature_flag_deletion_skill.py | 4 +- .../skills/implementations/function_skills.py | 4 +- .../implementations/global_var_skills.py | 4 +- .../graph_viz/graph_viz_app_imports.py | 2 +- .../graph_viz/graph_viz_call_graph.py | 12 ++--- .../graph_viz/graph_viz_dead_code.py | 2 +- .../graph_viz/graph_viz_dir_tree.py | 2 +- .../graph_viz/graph_viz_foreign_key.py | 2 +- .../code-quality-metrics/import-loops.py | 2 +- .../code-quality-metrics/large-files.py | 2 +- .../missing-documentation.py | 2 +- .../code-quality-metrics/unnamed-kwargs.py | 2 +- .../untyped-attributes.py | 2 +- .../untyped-parameters.py | 2 +- .../untyped-return-types.py | 2 +- .../implementations/guides/codebase-ai.py | 8 +-- .../guides/complex-renaming.py | 14 ++--- .../guides/creating-documentation.py | 10 ++-- .../guides/deleting-dead-code.py | 14 ++--- .../guides/increase-type-coverage.py | 20 +++---- .../guides/manipulating-collections.py | 16 +++--- .../guides/organize-your-codebase.py | 16 +++--- .../implementations/if_statement_skills.py | 4 +- .../implementations/move_symbols_skills.py | 4 +- .../type_inheritance_skills.py | 13 +++-- tests/unit/skills/test_skills.py | 2 +- 108 files changed, 510 insertions(+), 509 deletions(-) diff --git a/tests/integration/codegen/git/clients/test_github_client_factory.py b/tests/integration/codegen/git/clients/test_github_client_factory.py index 00e81d8cf..668faae0e 100644 --- a/tests/integration/codegen/git/clients/test_github_client_factory.py +++ b/tests/integration/codegen/git/clients/test_github_client_factory.py @@ -2,7 +2,7 @@ from codegen.git.schemas.github import GithubType -def test_github_client_factory_create_from_token_no_token() -> None: +def test_github_client_factory_create_from_token_no_token(): github_client = GithubClientFactory.create_from_token(github_type=GithubType.Github) assert github_client.base_url == "https://api.github.com" repo = github_client.read_client.get_repo("python-lsp/python-lsp-server") @@ -10,7 +10,7 @@ def test_github_client_factory_create_from_token_no_token() -> None: assert repo.name == "python-lsp-server" -def test_github_client_factory_create_from_repo(repo_config) -> None: +def test_github_client_factory_create_from_repo(repo_config): github_client = GithubClientFactory.create_from_repo(repo_config=repo_config, github_type=GithubType.Github) repo = github_client.read_client.get_repo("codegen-sh/Kevin-s-Adventure-Game") assert repo.full_name == "codegen-sh/Kevin-s-Adventure-Game" diff --git a/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py b/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py index f3f2ee97a..99604e0d4 100644 --- a/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py +++ b/tests/integration/codegen/git/repo_operator/test_remote_repo_operator.py @@ -18,7 +18,7 @@ def op(repo_config, request, tmpdir): @pytest.mark.parametrize("op", shallow_options, ids=lambda x: f"shallow={x}", indirect=True) @patch("codegen.git.clients.github_client.Github") -def test_checkout_branch(mock_git_client, op: RemoteRepoOperator) -> None: +def test_checkout_branch(mock_git_client, op: RemoteRepoOperator): mock_git_client.return_value = Github("test_token", "https://api.github.com") op.pull_repo() op.checkout_commit(op.head_commit) @@ -40,7 +40,7 @@ def test_checkout_branch(mock_git_client, op: RemoteRepoOperator) -> None: @pytest.mark.parametrize("op", [True], ids=lambda x: f"shallow={x}", indirect=True) @patch("codegen.git.clients.github_client.Github") -def test_checkout_branch_local_already_checked_out(mock_git_client, op: RemoteRepoOperator) -> None: +def test_checkout_branch_local_already_checked_out(mock_git_client, op: RemoteRepoOperator): mock_git_client.return_value = Github("test_token", "https://api.github.com") op.checkout_commit(op.head_commit) @@ -60,7 +60,7 @@ def test_checkout_branch_local_already_checked_out(mock_git_client, op: RemoteRe @pytest.mark.parametrize("op", [True], ids=lambda x: f"shallow={x}", indirect=True) @patch("codegen.git.clients.github_client.Github") -def test_checkout_branch_remote_already_checked_out_resets_branch(mock_git_client, op: RemoteRepoOperator) -> None: +def test_checkout_branch_remote_already_checked_out_resets_branch(mock_git_client, op: RemoteRepoOperator): mock_git_client.return_value = Github("test_token", "https://api.github.com") original_commit_head = op.head_commit diff --git a/tests/integration/codegen/test_imports.py b/tests/integration/codegen/test_imports.py index 7dc889965..e2af00f64 100644 --- a/tests/integration/codegen/test_imports.py +++ b/tests/integration/codegen/test_imports.py @@ -2,10 +2,10 @@ from codegen import Codebase -def test_codegen_imports() -> None: +def test_codegen_imports(): # Test decorated function @codegen.function(name="sample_codemod") - def run(codebase) -> None: + def run(codebase): pass # Test class diff --git a/tests/integration/codemod/test_diffs.py b/tests/integration/codemod/test_diffs.py index d0f59443b..5745caef2 100644 --- a/tests/integration/codemod/test_diffs.py +++ b/tests/integration/codemod/test_diffs.py @@ -21,7 +21,7 @@ def test_codemods_diffs(_codebase: Codebase, expected: Path) -> None: verify_diffs(_codebase) -def verify_diffs(_codebase) -> None: +def verify_diffs(_codebase): modified = gather_modified_files(_codebase) diffs = [DiffLite.from_git_diff(diff) for diff in _codebase.get_diffs()] _codebase.G.apply_diffs(diffs) diff --git a/tests/shared/codemod/codebase_comparison_utils.py b/tests/shared/codemod/codebase_comparison_utils.py index e2f8781f1..85659d307 100644 --- a/tests/shared/codemod/codebase_comparison_utils.py +++ b/tests/shared/codemod/codebase_comparison_utils.py @@ -149,7 +149,7 @@ def capture_single_file_stats(files_dir: Path, files, expected_dir: Path, extens return diff -def capture_modified_file_stats(left_lines: list[str], right_lines: list[str], diff_stats: dict) -> None: +def capture_modified_file_stats(left_lines: list[str], right_lines: list[str], diff_stats: dict): """Captures stats on the differences between two complementary files, a file that exists in both the expected and modified codebases. """ diff --git a/tests/shared/codemod/commands.py b/tests/shared/codemod/commands.py index 74bacc08c..b7d2984dc 100644 --- a/tests/shared/codemod/commands.py +++ b/tests/shared/codemod/commands.py @@ -23,24 +23,24 @@ def codemod() -> None: @codemod.command() @click.option("--extra-repos", is_flag=True) -def generate_cases(extra_repos: bool = False) -> None: +def generate_cases(extra_repos: bool = False): """Generate cases for codemod tests. Very slow""" repos = find_repos(extra_repos=extra_repos) for codemod in find_codemods(): - for repo_name in repos.keys(): + for repo_name, repo in repos.items(): (codemod.test_dir / f"test_{repo_name}").mkdir(parents=True, exist_ok=True) _generate_diffs(extra_repos=extra_repos) _clean_diffs(aggressive=True) -def _generate_diffs(extra_repos: bool = False) -> None: +def _generate_diffs(extra_repos: bool = False): """Generate diffs for codemod tests""" os.system(f"pytest tests/integration/codemod/test_codemods.py::test_codemods_cloned_repos --size small --extra-repos={str(extra_repos).lower()} -n auto --snapshot-update") os.system(f"pytest tests/integration/codemod/test_codemods.py::test_codemods_cloned_repos --size large --extra-repos={str(extra_repos).lower()} -n auto --snapshot-update") @codemod.command() -def generate_diffs() -> None: +def generate_diffs(): """Generate diffs for codemod tests""" _generate_diffs() _clean_diffs() @@ -67,7 +67,7 @@ def gather_repos_per_codemod() -> dict[str, dict[tuple[Size, bool], list[ClonedR MAX_CASES = {Size.Small: 1, Size.Large: 1} -def _clean_diffs(aggressive: bool = False) -> None: +def _clean_diffs(aggressive: bool = False): repos = {**find_repos(extra_repos=True), **find_repos(extra_repos=False)} for test_case in find_codemod_test_cases(repos=repos): @@ -93,7 +93,7 @@ def _clean_diffs(aggressive: bool = False) -> None: @codemod.command() @click.option("--aggressive", is_flag=True) -def clean_diffs(aggressive: bool = False) -> None: +def clean_diffs(aggressive: bool = False): _clean_diffs(aggressive) @@ -204,7 +204,7 @@ def _fetch_and_store_codemod(repo_id: str, url: str, cli_api_key: str) -> tuple[ @codemod.command() @click.option("--cli-api-key", required=True, help="API key for authentication") -def fetch_verified_codemods(cli_api_key: str) -> None: +def fetch_verified_codemods(cli_api_key: str): """Fetch codemods for all repos in REPO_ID_TO_URL and save to JSON files.""" VERIFIED_CODEMOD_DATA_DIR.mkdir(parents=True, exist_ok=True) repos_to_commits: dict[str, list[dict]] = {} diff --git a/tests/shared/codemod/verified_codemod_utils.py b/tests/shared/codemod/verified_codemod_utils.py index 0fb5ea40c..af5984158 100644 --- a/tests/shared/codemod/verified_codemod_utils.py +++ b/tests/shared/codemod/verified_codemod_utils.py @@ -83,7 +83,7 @@ def anonymized_name(self) -> str: class CodemodAPI: - def __init__(self, api_key: str | None = None, modal_prefix: str = "https://codegen-sh") -> None: + def __init__(self, api_key: str | None = None, modal_prefix: str = "https://codegen-sh"): self.api_key = api_key self.modal_prefix = modal_prefix self.get_codemods_url = f"{self.modal_prefix}--{GET_CODEMODS_URL_SUFFIX}" diff --git a/tests/shared/mocks/mock_ai_helper.py b/tests/shared/mocks/mock_ai_helper.py index 203d977b9..b163cfeb3 100644 --- a/tests/shared/mocks/mock_ai_helper.py +++ b/tests/shared/mocks/mock_ai_helper.py @@ -31,5 +31,5 @@ def llm_query_functions_with_retry(self, model: str, messages: list, functions: def llm_query_functions(self, model: str, messages: list, functions: list[dict], max_tokens: int | None = None) -> None: pass - def llm_response_to_json(self) -> str: + def llm_response_to_json(response) -> str: pass diff --git a/tests/shared/skills/decorators.py b/tests/shared/skills/decorators.py index 4b1179e3f..c6acec556 100644 --- a/tests/shared/skills/decorators.py +++ b/tests/shared/skills/decorators.py @@ -77,7 +77,7 @@ def properly_named_function(name: str, language: ProgrammingLanguage): return False -def skill_func_name_error(name: str, language: ProgrammingLanguage) -> str: +def skill_func_name_error(name: str, language: ProgrammingLanguage): if language == ProgrammingLanguage.PYTHON: return f"Function name must be 'skill_func', 'python_skill_func' or 'execute' for Python skills. Got {name}." elif language == ProgrammingLanguage.TYPESCRIPT: diff --git a/tests/shared/skills/skill.py b/tests/shared/skills/skill.py index 06525d4a7..17b695faa 100644 --- a/tests/shared/skills/skill.py +++ b/tests/shared/skills/skill.py @@ -29,7 +29,7 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: ... def typescript_skill_func(codebase: TSCodebaseType) -> callable: ... @staticmethod - def skill_func(codebase: CodebaseType) -> None: ... + def skill_func(codebase: CodebaseType): ... def execute(self, codebase: Codebase) -> None: ... diff --git a/tests/shared/skills/skill_implementation.py b/tests/shared/skills/skill_implementation.py index c2d3c2d79..dc83a7049 100644 --- a/tests/shared/skills/skill_implementation.py +++ b/tests/shared/skills/skill_implementation.py @@ -37,7 +37,7 @@ def __init__( si_id: int | None = None, from_app: bool = False, external: bool = False, - ) -> None: + ): self.name = name or skill_func.__name__ self.language = language self.test_cases = [] if skip_test else test_cases @@ -122,6 +122,6 @@ def function_body(self) -> str: def __call__(self, codebase: CodebaseType): self._skill_func(codebase) - def __str__(self) -> str: + def __str__(self): source = inspect.getsource(self._skill_func) return textwrap.dedent(source).strip() diff --git a/tests/shared/skills/utils.py b/tests/shared/skills/utils.py index f206e43f4..342d7d061 100644 --- a/tests/shared/skills/utils.py +++ b/tests/shared/skills/utils.py @@ -17,7 +17,7 @@ CODEMODS_PATH: Path = REPO_ROOT_PATH / "src" / "codemods" / "canonical" -def import_skills_from(path: Path, module_prefix: str) -> None: +def import_skills_from(path: Path, module_prefix: str): for file in path.rglob("*.py"): relative_path = file.relative_to(path) if "evaluation" in relative_path.parts or "__init__" in file.name: @@ -26,7 +26,7 @@ def import_skills_from(path: Path, module_prefix: str) -> None: importlib.import_module(module) -def import_all_skills() -> None: +def import_all_skills(): import_skills_from(SKILLS_PATH, "tests.unit.skills.implementations") import_skills_from(CODEMODS_PATH, "codemods.canonical") diff --git a/tests/shared/utils/recursion.py b/tests/shared/utils/recursion.py index 2c5e4fbae..c816a4fab 100644 --- a/tests/shared/utils/recursion.py +++ b/tests/shared/utils/recursion.py @@ -5,7 +5,7 @@ logger = logging.getLogger(__name__) -def set_recursion_limit() -> None: +def set_recursion_limit(): sys.setrecursionlimit(10**9) if sys.platform == "linux": logger.info(f"Setting stack limit to {resource.RLIM_INFINITY}") diff --git a/tests/unit/codegen/cli/test_reset.py b/tests/unit/codegen/cli/test_reset.py index ae0c235e5..cbbbb19fd 100644 --- a/tests/unit/codegen/cli/test_reset.py +++ b/tests/unit/codegen/cli/test_reset.py @@ -47,7 +47,7 @@ def committed_repo(initialized_repo: Path, committed_state: dict[str, str]) -> P return initialized_repo -def setup_repo_state(repo_path: Path, state: dict[str, str]) -> None: +def setup_repo_state(repo_path: Path, state: dict[str, str]): """Helper to set up files in the repo""" for filepath, content in state.items(): file_path = repo_path / filepath @@ -93,7 +93,7 @@ def get_git_status(repo_path: Path) -> tuple[set[str], set[str], set[str]]: def verify_git_state( repo_path: Path, expected_staged: set[str] | None = None, expected_modified: set[str] | None = None, expected_untracked: set[str] | None = None, rename_pairs: list[tuple[str, str]] | None = None -) -> None: +): """Verify git status matches expected state""" if rename_pairs is not None: for old_path, new_path in rename_pairs: @@ -114,7 +114,7 @@ def verify_git_state( assert untracked == expected_untracked, f"Untracked files mismatch.\nExpected: {expected_untracked}\nActual: {untracked}" -def verify_repo_state(repo_path: Path, expected_content: dict[str, str | None]) -> None: +def verify_repo_state(repo_path: Path, expected_content: dict[str, str | None]): """Verify file contents in repo""" for path, content in expected_content.items(): file_path = repo_path / path @@ -265,7 +265,7 @@ def create_test_case( ), ], ) -def test_reset(committed_repo: Path, committed_state: dict[str, str], test_case: ResetTestCase, runner: CliRunner) -> None: +def test_reset(committed_repo: Path, committed_state: dict[str, str], test_case: ResetTestCase, runner: CliRunner): """Test reset command with various scenarios""" # Get test case from factory function if needed if callable(test_case): @@ -299,7 +299,7 @@ def test_reset(committed_repo: Path, committed_state: dict[str, str], test_case: ) -def test_reset_with_mixed_states(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner) -> None: +def test_reset_with_mixed_states(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner): """Test reset with a mix of staged, unstaged, and untracked changes""" # 1. Staged modifications staged_changes = { @@ -348,7 +348,7 @@ def test_reset_with_mixed_states(committed_repo: Path, committed_state: dict[str ) -def test_reset_with_mixed_renames(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner) -> None: +def test_reset_with_mixed_renames(committed_repo: Path, committed_state: dict[str, str], runner: CliRunner): """Test reset with a mix of staged and unstaged renames""" # 1. Staged rename staged_changes = { diff --git a/tests/unit/codegen/git/clients/test_git_repo_client.py b/tests/unit/codegen/git/clients/test_git_repo_client.py index d2b2cace0..c729dc9a6 100644 --- a/tests/unit/codegen/git/clients/test_git_repo_client.py +++ b/tests/unit/codegen/git/clients/test_git_repo_client.py @@ -7,7 +7,7 @@ @patch("codegen.git.clients.git_repo_client.GithubClientFactory") def test_delete_branch_default( mock_github_client_factory, -) -> None: +): git_repo_client = GitRepoClient(repo_config=MagicMock(), access_scope=GithubScope.WRITE) git_repo_client.read_client = MagicMock(default_branch="default-branch") git_repo_client.delete_branch(branch_name="default-branch") @@ -18,7 +18,7 @@ def test_delete_branch_default( @patch("codegen.git.clients.git_repo_client.GithubClientFactory") def test_delete_branch_non_default_branch( mock_github_client_factory, -) -> None: +): git_repo_client = GitRepoClient(repo_config=MagicMock(), access_scope=GithubScope.WRITE) git_repo_client.read_client = MagicMock(default_branch="default-branch") mock_ref = MagicMock() @@ -30,7 +30,7 @@ def test_delete_branch_non_default_branch( @patch("codegen.git.clients.git_repo_client.GithubClientFactory") def test_delete_branch_cannot_write_branch( mock_github_client_factory, -) -> None: +): git_repo_client = GitRepoClient(repo_config=MagicMock(), access_scope=GithubScope.WRITE) git_repo_client.read_client = MagicMock(default_branch="default-branch") git_repo_client.delete_branch(branch_name="not-default-branch") diff --git a/tests/unit/codegen/git/schemas/test_github.py b/tests/unit/codegen/git/schemas/test_github.py index a875b58ca..26d2b4d3a 100644 --- a/tests/unit/codegen/git/schemas/test_github.py +++ b/tests/unit/codegen/git/schemas/test_github.py @@ -1,6 +1,6 @@ from codegen.git.schemas.github import GithubType -def test_github_type_base_url() -> None: +def test_github_type_base_url(): assert GithubType.Github.base_url == "https://github.com" assert GithubType.GithubEnterprise.base_url == "https://github.codegen.app" diff --git a/tests/unit/codegen/gscli/test_cli.py b/tests/unit/codegen/gscli/test_cli.py index 96c11bdae..9c3356d96 100644 --- a/tests/unit/codegen/gscli/test_cli.py +++ b/tests/unit/codegen/gscli/test_cli.py @@ -1,2 +1,2 @@ -def test_cli() -> None: +def test_cli(): import codegen.gscli # noqa: F401 diff --git a/tests/unit/codegen/runner/sandbox/test_executor.py b/tests/unit/codegen/runner/sandbox/test_executor.py index 60094b061..0c1fa5f7a 100644 --- a/tests/unit/codegen/runner/sandbox/test_executor.py +++ b/tests/unit/codegen/runner/sandbox/test_executor.py @@ -17,7 +17,7 @@ @pytest.mark.asyncio -async def test_execute_func_pass_in_codemod_context_takes_priority(executor: SandboxExecutor) -> None: +async def test_execute_func_pass_in_codemod_context_takes_priority(executor: SandboxExecutor): codemod_context = CodemodContext( CODEMOD_LINK="http://codegen.sh/codemod/5678", ) @@ -85,7 +85,7 @@ async def test_execute_func_pass_in_codemod_context_takes_priority(executor: San @pytest.mark.asyncio -async def test_run_max_preview_time_exceeded_sets_observation_meta(executor: SandboxExecutor) -> None: +async def test_run_max_preview_time_exceeded_sets_observation_meta(executor: SandboxExecutor): mock_source = """ codebase.files[0].edit("a = 2") """ @@ -97,7 +97,7 @@ async def test_run_max_preview_time_exceeded_sets_observation_meta(executor: San @pytest.mark.asyncio -async def test_run_max_ai_requests_error_sets_observation_meta(executor: SandboxExecutor) -> None: +async def test_run_max_ai_requests_error_sets_observation_meta(executor: SandboxExecutor): mock_source = """ codebase.ai("tell me a joke") """ @@ -109,7 +109,7 @@ async def test_run_max_ai_requests_error_sets_observation_meta(executor: Sandbox @pytest.mark.asyncio -async def test_run_max_transactions_exceeded_sets_observation_meta(executor: SandboxExecutor) -> None: +async def test_run_max_transactions_exceeded_sets_observation_meta(executor: SandboxExecutor): mock_source = """ codebase.files[0].edit("a = 2") """ @@ -122,7 +122,7 @@ async def test_run_max_transactions_exceeded_sets_observation_meta(executor: San @pytest.mark.asyncio -async def test_find_flag_groups_with_subdirectories(executor: SandboxExecutor) -> None: +async def test_find_flag_groups_with_subdirectories(executor: SandboxExecutor): groups = await executor.find_flag_groups( code_flags=[ CodeFlag( @@ -151,7 +151,7 @@ async def test_find_flag_groups_with_subdirectories(executor: SandboxExecutor) - @pytest.mark.asyncio -async def test_find_flag_groups_with_group_by(executor: SandboxExecutor) -> None: +async def test_find_flag_groups_with_group_by(executor: SandboxExecutor): groups = await executor.find_flag_groups( code_flags=[ CodeFlag( @@ -185,7 +185,7 @@ async def test_find_flag_groups_with_group_by(executor: SandboxExecutor) -> None @pytest.mark.asyncio @pytest.mark.parametrize("codebase", [121], indirect=True) -async def test_find_flag_groups_with_group_by_app(executor: SandboxExecutor) -> None: +async def test_find_flag_groups_with_group_by_app(executor: SandboxExecutor): groups = await executor.find_flag_groups( code_flags=[ CodeFlag( @@ -213,7 +213,7 @@ async def test_find_flag_groups_with_group_by_app(executor: SandboxExecutor) -> @pytest.mark.skip(reason="TODO: add max_prs as part of find_flag_groups") @pytest.mark.asyncio -async def test_find_flag_groups_with_max_prs(executor: SandboxExecutor) -> None: +async def test_find_flag_groups_with_max_prs(executor: SandboxExecutor): groups = await executor.find_flag_groups( code_flags=[ CodeFlag( diff --git a/tests/unit/codegen/runner/sandbox/test_runner.py b/tests/unit/codegen/runner/sandbox/test_runner.py index b1fb3a81d..0abd5c557 100644 --- a/tests/unit/codegen/runner/sandbox/test_runner.py +++ b/tests/unit/codegen/runner/sandbox/test_runner.py @@ -7,7 +7,7 @@ @pytest.mark.asyncio @patch("codegen.runner.sandbox.executor.SandboxExecutor") -async def test_sandbox_runner_warmup_builds_graph(mock_executor, runner: SandboxRunner) -> None: +async def test_sandbox_runner_warmup_builds_graph(mock_executor, runner: SandboxRunner): await runner.warmup() assert runner.codebase.files assert len(runner.codebase.files) == 1 @@ -15,7 +15,7 @@ async def test_sandbox_runner_warmup_builds_graph(mock_executor, runner: Sandbox @pytest.mark.asyncio @patch("codegen.runner.sandbox.runner.SandboxRunner._build_graph") -async def test_sandbox_runner_warmup_builds_graph_throws(mock_build_graph, runner: SandboxRunner) -> None: +async def test_sandbox_runner_warmup_builds_graph_throws(mock_build_graph, runner: SandboxRunner): mock_build_graph.side_effect = Exception("Test exception") with pytest.raises(Exception): @@ -25,7 +25,7 @@ async def test_sandbox_runner_warmup_builds_graph_throws(mock_build_graph, runne @pytest.mark.asyncio @patch("codegen.runner.sandbox.runner.logger") @patch("codegen.runner.sandbox.runner.SandboxExecutor") -async def test_sandbox_runner_warmup_logs_repo_id(mock_executor, mock_logger, runner: SandboxRunner) -> None: +async def test_sandbox_runner_warmup_logs_repo_id(mock_executor, mock_logger, runner: SandboxRunner): await runner.warmup() assert runner.codebase.files assert len(runner.codebase.files) == 1 @@ -35,7 +35,7 @@ async def test_sandbox_runner_warmup_logs_repo_id(mock_executor, mock_logger, ru @pytest.mark.asyncio @patch("codegen.runner.sandbox.runner.SandboxExecutor") -async def test_sandbox_runner_warmup_starts_with_default_branch(mock_executor, runner: SandboxRunner) -> None: +async def test_sandbox_runner_warmup_starts_with_default_branch(mock_executor, runner: SandboxRunner): await runner.warmup() # assert True is returned # assert len(runner.codebase._op.git_cli.branches) == 1 TODO: fix GHA creating master and main branch assert not runner.codebase._op.git_cli.head.is_detached @@ -47,7 +47,7 @@ async def test_sandbox_runner_warmup_starts_with_default_branch(mock_executor, r @patch("codegen.runner.sandbox.runner.logger") @patch("codegen.runner.sandbox.runner.SandboxExecutor") @patch("codegen.sdk.core.codebase.Codebase.default_branch", new_callable=PropertyMock) -async def test_sandbox_runner_reset_runner_deletes_branches(mock_branch, mock_executor, mock_logger, runner: SandboxRunner) -> None: +async def test_sandbox_runner_reset_runner_deletes_branches(mock_branch, mock_executor, mock_logger, runner: SandboxRunner): mock_branch.return_value = "main" await runner.warmup() num_branches = len(runner.codebase._op.git_cli.heads) # TODO: fix GHA creating master and main branch and assert the len is 1 at the start diff --git a/tests/unit/codegen/runner/utils/test_branch_name.py b/tests/unit/codegen/runner/utils/test_branch_name.py index 7aae328db..6b3d807a5 100644 --- a/tests/unit/codegen/runner/utils/test_branch_name.py +++ b/tests/unit/codegen/runner/utils/test_branch_name.py @@ -3,13 +3,13 @@ from codegen.runner.utils.branch_name import get_head_branch_name -def test_get_head_branch_name_no_group() -> None: +def test_get_head_branch_name_no_group(): codemod = MagicMock(epic_id=123, version_id=456, run_id=789) branch_name = get_head_branch_name(codemod=codemod, group=None) assert branch_name == "codegen-codemod-123-version-456-run-789-group-0" -def test_get_head_branch_name_with_group() -> None: +def test_get_head_branch_name_with_group(): codemod = MagicMock(epic_id=123, version_id=456, run_id=789) group = MagicMock(id=2) branch_name = get_head_branch_name(codemod=codemod, group=group) diff --git a/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py b/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py index f9f74fb1a..3a8ebf689 100644 --- a/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py +++ b/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py @@ -22,13 +22,13 @@ def setup_codebase(num_files: int, extension: str, tmp_path: Path): return codebase, files -def reset_codebase(codebase: Codebase) -> None: +def reset_codebase(codebase: Codebase): codebase.reset() @pytest.mark.benchmark(group="sdk-benchmark", min_time=1, max_time=5, disable_gc=True) @pytest.mark.parametrize("extension", ["txt", "py"]) -def test_codebase_reset_stress_test(extension: str, tmp_path, benchmark) -> None: +def test_codebase_reset_stress_test(extension: str, tmp_path, benchmark): def setup(): codebase, _ = setup_codebase(NUM_FILES, extension, tmp_path) return ((codebase,), {}) @@ -38,7 +38,7 @@ def setup(): @pytest.mark.timeout(5, func_only=True) @pytest.mark.parametrize("extension", ["txt", "py"]) -def test_codebase_reset_correctness(extension: str, tmp_path) -> None: +def test_codebase_reset_correctness(extension: str, tmp_path): codebase, files = setup_codebase(NUM_FILES, extension, tmp_path) codebase.reset() for file, original_content in files.items(): diff --git a/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py b/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py index 4e6b695c8..39e2fc20b 100644 --- a/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py +++ b/tests/unit/codegen/sdk/code_generation/test_codemod_writer_decorators.py @@ -8,7 +8,7 @@ @pytest.mark.skip("broken after repo split, fix or move over") -def test_get_documented_objects() -> None: +def test_get_documented_objects(): """Test that importing everything in codegen-sdk doesn't invoke any functionality (incase someone leaves actual functionality at the top level of a file). diff --git a/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py b/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py index c61a26308..a084ae143 100644 --- a/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py +++ b/tests/unit/codegen/sdk/codebase/codebase_graph/test_codebase_reset.py @@ -10,7 +10,7 @@ ], indirect=["original", "expected"], ) -def test_codebase_reset(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset(codebase: Codebase, assert_expected, tmp_path): # External change should be preserved (tmp_path / "a.py").write_text("b") # Programmatic change should be reset @@ -27,7 +27,7 @@ def test_codebase_reset(codebase: Codebase, assert_expected, tmp_path) -> None: ], indirect=["original", "expected"], ) -def test_codebase_reset_external_changes(codebase: Codebase, assert_expected) -> None: +def test_codebase_reset_external_changes(codebase: Codebase, assert_expected): # External change should be preserved codebase.get_file("a.py").path.write_text("b") codebase.commit() @@ -42,7 +42,7 @@ def test_codebase_reset_external_changes(codebase: Codebase, assert_expected) -> ], indirect=["original", "expected"], ) -def test_codebase_reset_manual_file_add(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset_manual_file_add(codebase: Codebase, assert_expected, tmp_path): # Manually create a new file - should be preserved new_file = tmp_path / "new.py" new_file.write_text("new content") @@ -60,7 +60,7 @@ def test_codebase_reset_manual_file_add(codebase: Codebase, assert_expected, tmp ], indirect=["original", "expected"], ) -def test_codebase_reset_manual_file_delete(codebase: Codebase, assert_expected) -> None: +def test_codebase_reset_manual_file_delete(codebase: Codebase, assert_expected): # Manual deletion should be preserved codebase.get_file("b.py").path.unlink() # Programmatic change should be reset @@ -77,7 +77,7 @@ def test_codebase_reset_manual_file_delete(codebase: Codebase, assert_expected) ], indirect=["original", "expected"], ) -def test_codebase_reset_manual_file_rename(codebase: Codebase, tmp_path, assert_expected) -> None: +def test_codebase_reset_manual_file_rename(codebase: Codebase, tmp_path, assert_expected): # Manual rename should be preserved old_path = codebase.get_file("old.py").path new_path = tmp_path / "new.py" @@ -104,7 +104,7 @@ def test_codebase_reset_manual_file_rename(codebase: Codebase, tmp_path, assert_ ], indirect=["original", "expected"], ) -def test_codebase_reset_nested_directories(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset_nested_directories(codebase: Codebase, assert_expected, tmp_path): """Test reset with nested directory structure.""" # External changes should be preserved (tmp_path / "src/main.py").write_text("def main():\n print('modified')") @@ -133,7 +133,7 @@ def test_codebase_reset_nested_directories(codebase: Codebase, assert_expected, ], indirect=["original", "expected"], ) -def test_codebase_reset_mixed_content(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset_mixed_content(codebase: Codebase, assert_expected, tmp_path): """Test reset with different types of file content.""" # External changes should be preserved (tmp_path / "config.json").write_text('{\n "debug": false,\n "env": "prod"\n}') @@ -187,7 +187,7 @@ def reset(self): ], indirect=["original", "expected"], ) -def test_codebase_reset_large_file(codebase: Codebase, assert_expected) -> None: +def test_codebase_reset_large_file(codebase: Codebase, assert_expected): """Test reset with a larger file containing multiple methods.""" codebase.get_file("module.py").edit("""class ModifiedClass: def __init__(self): @@ -204,7 +204,7 @@ def __init__(self): ], indirect=["original", "expected"], ) -def test_codebase_reset_preserves_external_changes(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset_preserves_external_changes(codebase: Codebase, assert_expected, tmp_path): # Make external changes to existing file src_dir = tmp_path / "src" src_dir.mkdir(exist_ok=True) @@ -229,7 +229,7 @@ def test_codebase_reset_preserves_external_changes(codebase: Codebase, assert_ex ], indirect=["original", "expected"], ) -def test_codebase_reset_mixed_changes(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset_mixed_changes(codebase: Codebase, assert_expected, tmp_path): # Make programmatic change that should be reset codebase.get_file("src/utils.py").edit("def helper():\n return None") @@ -250,7 +250,7 @@ def test_codebase_reset_mixed_changes(codebase: Codebase, assert_expected, tmp_p ], indirect=["original", "expected"], ) -def test_codebase_reset_nested_external_changes(codebase: Codebase, assert_expected, tmp_path) -> None: +def test_codebase_reset_nested_external_changes(codebase: Codebase, assert_expected, tmp_path): # Create nested directory structure with changes config_dir = tmp_path / "config" config_dir.mkdir(exist_ok=True) @@ -277,7 +277,7 @@ def test_codebase_reset_nested_external_changes(codebase: Codebase, assert_expec ], indirect=["original", "expected"], ) -def test_codebase_reset_multiple_programmatic_edits(codebase: Codebase, assert_expected) -> None: +def test_codebase_reset_multiple_programmatic_edits(codebase: Codebase, assert_expected): """Test reset after multiple programmatic edits to the same file.""" # Make multiple programmatic changes that should all be reset codebase.get_file("file.py").edit("first edit") @@ -302,7 +302,7 @@ def test_codebase_reset_multiple_programmatic_edits(codebase: Codebase, assert_e ], indirect=["original", "expected"], ) -def test_codebase_reset_interleaved_changes(codebase: Codebase, assert_expected) -> None: +def test_codebase_reset_interleaved_changes(codebase: Codebase, assert_expected): """Test reset with interleaved programmatic and external changes.""" # Interleave programmatic and external changes codebase.get_file("file.py").edit("def main():\n return 1") @@ -335,7 +335,7 @@ def method1(self): ], indirect=["original", "expected"], ) -def test_codebase_reset_complex_changes(codebase: Codebase, assert_expected) -> None: +def test_codebase_reset_complex_changes(codebase: Codebase, assert_expected): """Test reset with a mix of content additions, modifications, and external changes.""" # Make several programmatic changes for i in range(5): diff --git a/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py b/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py index 017f1163d..5eb6e77e2 100644 --- a/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py +++ b/tests/unit/codegen/sdk/codebase/file_graph/test_symbol_parent_statement.py @@ -6,7 +6,7 @@ from codegen.sdk.python import PyFile -def test_parent_statement_function(tmpdir) -> None: +def test_parent_statement_function(tmpdir): # language=python content = """ def foo(): @@ -17,7 +17,7 @@ def foo(): assert codebase.get_function("foo").parent_statement == file.code_block.statements[0] -def test_parent_statement_class(tmpdir) -> None: +def test_parent_statement_class(tmpdir): # language=python content = """ class Foo: @@ -28,7 +28,7 @@ class Foo: assert codebase.get_class("Foo").parent_statement == file.code_block.statements[0] -def test_parent_statement_assignment(tmpdir) -> None: +def test_parent_statement_assignment(tmpdir): # language=python content = """ foo = 1 @@ -38,7 +38,7 @@ def test_parent_statement_assignment(tmpdir) -> None: assert file.get_global_var("foo").parent_statement == file.code_block.statements[0] -def test_parent_statement_nested_symbols(tmpdir) -> None: +def test_parent_statement_nested_symbols(tmpdir): # language=python content = """ logger = get_logger() diff --git a/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py b/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py index 1491360a6..d7beba6ec 100644 --- a/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py +++ b/tests/unit/codegen/sdk/codebase/flagging/test_code_flag.py @@ -2,7 +2,7 @@ from codegen.sdk.codebase.flagging.enums import MessageType -def test_code_flag_properties(tmpdir) -> None: +def test_code_flag_properties(tmpdir): # language=python content = """ class Foo: diff --git a/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py b/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py index be07f8c93..179a6ffb2 100644 --- a/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py +++ b/tests/unit/codegen/sdk/codebase/flagging/test_group_all.py @@ -4,7 +4,7 @@ from codegen.sdk.codebase.flagging.groupers.all_grouper import AllGrouper -def test_group_all() -> None: +def test_group_all(): flag1 = CodeFlag( symbol=MagicMock( file=MagicMock(filepath="test.py"), diff --git a/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py b/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py index b3c30ae73..807559392 100644 --- a/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py +++ b/tests/unit/codegen/sdk/codebase/transaction_manager/test_transaction_mangager_checks.py @@ -6,7 +6,7 @@ from codegen.shared.exceptions.control_flow import MaxPreviewTimeExceeded, MaxTransactionsExceeded -def test_check_max_preview_time_exceeded(tmpdir) -> None: +def test_check_max_preview_time_exceeded(tmpdir): with pytest.raises(MaxPreviewTimeExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -20,7 +20,7 @@ def test_check_max_preview_time_exceeded(tmpdir) -> None: assert exc_info.value.threshold == 0 -def test_check_max_preview_time_exceeded_set_session_options(tmpdir) -> None: +def test_check_max_preview_time_exceeded_set_session_options(tmpdir): with get_codebase_session( tmpdir=tmpdir, files={"file_a.py": "a = 1", "file_b": "b = 1"}, @@ -34,7 +34,7 @@ def test_check_max_preview_time_exceeded_set_session_options(tmpdir) -> None: assert exc_info.value.threshold == 0 -def test_check_max_transactions_exceeded(tmpdir) -> None: +def test_check_max_transactions_exceeded(tmpdir): with pytest.raises(MaxTransactionsExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -48,7 +48,7 @@ def test_check_max_transactions_exceeded(tmpdir) -> None: assert exc_info.value.threshold == 0 -def test_check_max_transactions_exceeded_set_session_options(tmpdir) -> None: +def test_check_max_transactions_exceeded_set_session_options(tmpdir): with get_codebase_session( tmpdir=tmpdir, files={"file_a.py": "a = 1", "file_b": "b = 1"}, diff --git a/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py b/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py index 8aedd9ba3..a183ea2ef 100644 --- a/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py +++ b/tests/unit/codegen/sdk/python/codebase/test_codebase_raise_error.py @@ -4,7 +4,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_python_exports_not_supported(tmpdir) -> None: +def test_python_exports_not_supported(tmpdir): """Test that exports are not supported in Python codebases.""" # language=python content = """ diff --git a/tests/unit/codegen/sdk/python/codebase/test_control_flow.py b/tests/unit/codegen/sdk/python/codebase/test_control_flow.py index 4aaa7c5dc..589f2a2fd 100644 --- a/tests/unit/codegen/sdk/python/codebase/test_control_flow.py +++ b/tests/unit/codegen/sdk/python/codebase/test_control_flow.py @@ -1,5 +1,3 @@ -from typing import NoReturn - import pytest from codegen.sdk.codebase.config import SessionOptions @@ -9,13 +7,13 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_max_transactions_exceeded_reached_set_threshold(tmpdir) -> None: +def test_max_transactions_exceeded_reached_set_threshold(tmpdir): e = MaxTransactionsExceeded("test exception", threshold=1) assert str(e) == "test exception" assert e.threshold == 1 -def test_raise_max_transactions_exceeded_reached_no_threshold(tmpdir) -> NoReturn: +def test_raise_max_transactions_exceeded_reached_no_threshold(tmpdir): with pytest.raises(MaxTransactionsExceeded) as exc_info: msg = "test exception" raise MaxTransactionsExceeded(msg) @@ -23,7 +21,7 @@ def test_raise_max_transactions_exceeded_reached_no_threshold(tmpdir) -> NoRetur assert exc_info.value.threshold is None -def test_raise_max_transactions_exceeded_reached_with_threshold(tmpdir) -> NoReturn: +def test_raise_max_transactions_exceeded_reached_with_threshold(tmpdir): with pytest.raises(MaxTransactionsExceeded) as exc_info: msg = "test exception" raise MaxTransactionsExceeded(msg, threshold=1) @@ -31,7 +29,7 @@ def test_raise_max_transactions_exceeded_reached_with_threshold(tmpdir) -> NoRet assert exc_info.value.threshold == 1 -def test_max_transactions_exceeded_reached(tmpdir) -> None: +def test_max_transactions_exceeded_reached(tmpdir): with pytest.raises(MaxTransactionsExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -45,7 +43,7 @@ def test_max_transactions_exceeded_reached(tmpdir) -> None: assert exc_info.value.threshold == 1 -def test_max_transactions_exceeded_reached_should_still_commit(tmpdir) -> None: +def test_max_transactions_exceeded_reached_should_still_commit(tmpdir): with pytest.raises(MaxTransactionsExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -61,7 +59,7 @@ def test_max_transactions_exceeded_reached_should_still_commit(tmpdir) -> None: assert exc_info.value.threshold == 1 -def test_max_preview_time_exceeded_reached(tmpdir) -> None: +def test_max_preview_time_exceeded_reached(tmpdir): with pytest.raises(MaxPreviewTimeExceeded) as exc_info: with get_codebase_session( tmpdir=tmpdir, @@ -75,7 +73,7 @@ def test_max_preview_time_exceeded_reached(tmpdir) -> None: assert exc_info.value.threshold == 0 -def test_max_ai_requests_error_reached(tmpdir) -> None: +def test_max_ai_requests_error_reached(tmpdir): with pytest.raises(MaxAIRequestsError) as exc_info: with get_codebase_session( tmpdir=tmpdir, diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py index 13d38ea7e..4bd8a726f 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_indent.py @@ -7,7 +7,7 @@ from codegen.sdk.python import PyFile -def test_indent_left_once(tmpdir) -> None: +def test_indent_left_once(tmpdir): # language=python content = """ def foo(): @@ -32,7 +32,7 @@ def foo(): ) -def test_indent_left_exceed_limit(tmpdir) -> None: +def test_indent_left_exceed_limit(tmpdir): # language=python content = """ def foo(): @@ -57,7 +57,7 @@ def foo(): ) -def test_indent_right_once(tmpdir) -> None: +def test_indent_right_once(tmpdir): # language=python content = """ def foo(): @@ -82,7 +82,7 @@ def foo(): ) -def test_indent_right_multiple(tmpdir) -> None: +def test_indent_right_multiple(tmpdir): # language=python content = """ def foo(): @@ -107,7 +107,7 @@ def foo(): ) -def test_indent_zero(tmpdir) -> None: +def test_indent_zero(tmpdir): # language=python content = """ def foo(): @@ -122,7 +122,7 @@ def foo(): assert file.content == content -def test_indent_nested_code_blocks(tmpdir) -> None: +def test_indent_nested_code_blocks(tmpdir): # language=python content = """ def foo(): @@ -181,7 +181,7 @@ def foo(): ) -def test_indent_only_nested_block(tmpdir) -> None: +def test_indent_only_nested_block(tmpdir): # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py index d96496c04..1b29bb754 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_insert.py @@ -1,7 +1,7 @@ from codegen.sdk.codebase.factory.get_session import get_codebase_session -def test_code_block_append_single_element(tmpdir) -> None: +def test_code_block_append_single_element(tmpdir): # language=python content = """ def foo(): @@ -27,7 +27,7 @@ def foo(): ) -def test_code_block_append_multiple_element(tmpdir) -> None: +def test_code_block_append_multiple_element(tmpdir): # language=python content = """ def foo(): @@ -55,7 +55,7 @@ def foo(): ) -def test_code_block_insert_single_element_beginning(tmpdir) -> None: +def test_code_block_insert_single_element_beginning(tmpdir): # language=python content = """ def foo(): @@ -81,7 +81,7 @@ def foo(): ) -def test_code_block_insert_multiple_element_beginning(tmpdir) -> None: +def test_code_block_insert_multiple_element_beginning(tmpdir): # language=python content = """ def foo(): @@ -109,7 +109,7 @@ def foo(): ) -def test_code_block_insert_single_element_middle(tmpdir) -> None: +def test_code_block_insert_single_element_middle(tmpdir): # language=python content = """ def foo(): @@ -135,7 +135,7 @@ def foo(): ) -def test_code_block_insert_multiple_element_middle(tmpdir) -> None: +def test_code_block_insert_multiple_element_middle(tmpdir): # language=python content = """ def foo(): @@ -163,7 +163,7 @@ def foo(): ) -def test_code_block_insert_single_element_end(tmpdir) -> None: +def test_code_block_insert_single_element_end(tmpdir): # language=python content = """ def foo(): @@ -189,7 +189,7 @@ def foo(): ) -def test_code_block_insert_multiple_element_end(tmpdir) -> None: +def test_code_block_insert_multiple_element_end(tmpdir): # language=python content = """ def foo(): @@ -217,7 +217,7 @@ def foo(): ) -def test_code_block_insert_multiple_out_of_order(tmpdir) -> None: +def test_code_block_insert_multiple_out_of_order(tmpdir): # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py index 41a0d8349..5c58933eb 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_remove.py @@ -1,7 +1,7 @@ from codegen.sdk.codebase.factory.get_session import get_codebase_session -def test_code_block_remove_multiple_element(tmpdir) -> None: +def test_code_block_remove_multiple_element(tmpdir): # language=python content = """ def foo(): @@ -25,7 +25,7 @@ def foo(): ) -def test_code_block_remove_insert_beginning(tmpdir) -> None: +def test_code_block_remove_insert_beginning(tmpdir): # language=python content = """ def foo(): @@ -51,7 +51,7 @@ def foo(): ) -def test_code_block_insert_remove_beginning(tmpdir) -> None: +def test_code_block_insert_remove_beginning(tmpdir): # language=python content = """ def foo(): @@ -77,7 +77,7 @@ def foo(): ) -def test_code_block_remove_insert_middle(tmpdir) -> None: +def test_code_block_remove_insert_middle(tmpdir): # language=python content = """ def foo(): @@ -103,7 +103,7 @@ def foo(): ) -def test_code_block_insert_remove_middle(tmpdir) -> None: +def test_code_block_insert_remove_middle(tmpdir): # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py index 8bf67b3eb..df9419975 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_unwrap.py @@ -7,7 +7,7 @@ from codegen.sdk.python import PyFile -def test_unwrap_flat_statements(tmpdir) -> None: +def test_unwrap_flat_statements(tmpdir): # language=python content = """ def foo(): @@ -36,7 +36,7 @@ def foo(): ) -def test_unwrap_nested_statements(tmpdir) -> None: +def test_unwrap_nested_statements(tmpdir): # language=python content = """ def foo(): @@ -72,7 +72,7 @@ def foo(): ) -def test_unwrap_sandwiched_statements(tmpdir) -> None: +def test_unwrap_sandwiched_statements(tmpdir): # language=python content = """ def foo(): @@ -108,7 +108,7 @@ def foo(): ) -def test_unwrap_multiline_wrapper(tmpdir) -> None: +def test_unwrap_multiline_wrapper(tmpdir): # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py index 5fbd475ed..046be8ff5 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/code_block/test_code_block_wrap.py @@ -6,7 +6,7 @@ from codegen.sdk.python import PyFile -def test_wrap_with_with_statement(tmpdir) -> None: +def test_wrap_with_with_statement(tmpdir): # language=python content = """ def foo(a: bool): @@ -33,7 +33,7 @@ def foo(a: bool): ) -def test_wrap_with_function(tmpdir) -> None: +def test_wrap_with_function(tmpdir): # language=python content = """ if a: diff --git a/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py b/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py index e6dc799b2..9dd786afa 100644 --- a/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py +++ b/tests/unit/codegen/sdk/python/detached_symbols/function_call/test_function_calls_from_symbol.py @@ -10,7 +10,7 @@ from codegen.sdk.python.statements.if_block_statement import PyIfBlockStatement -def test_function_calls_from_file(tmpdir) -> None: +def test_function_calls_from_file(tmpdir): # language=python content = """ from some_file import x, y, z @@ -45,7 +45,7 @@ def random(): ] -def test_function_calls_from_class(tmpdir) -> None: +def test_function_calls_from_class(tmpdir): # language=python content = """ from some_file import bar @@ -86,7 +86,7 @@ def foo(self): assert third_call.parent.statement_type == StatementType.RETURN_STATEMENT -def test_function_calls_from_decorated_definitions(tmpdir) -> None: +def test_function_calls_from_decorated_definitions(tmpdir): # language=python content = """ @pytest.mark.parametrize("x", [1, 2, 3]) @@ -124,7 +124,7 @@ def __init__(self): @pytest.mark.xfail(reason="Broken by function call changes") -def test_function_calls_from_datatypes(tmpdir) -> None: +def test_function_calls_from_datatypes(tmpdir): # language=python content = """ def get_config(): @@ -168,7 +168,7 @@ def get_config(): ] -def test_function_calls_from_function_parameters(tmpdir) -> None: +def test_function_calls_from_function_parameters(tmpdir): # language=python content = """ # function parameters @@ -189,7 +189,7 @@ def greet(name=get_default_name()): ] -def test_function_calls_from_while_loop(tmpdir) -> None: +def test_function_calls_from_while_loop(tmpdir): # language=python content = """ # while loop conditions @@ -209,7 +209,7 @@ def test_function_calls_from_while_loop(tmpdir) -> None: ] -def test_function_calls_from_if_conditions(tmpdir) -> None: +def test_function_calls_from_if_conditions(tmpdir): # language=python content = """ # if conditions @@ -233,7 +233,7 @@ def test_function_calls_from_if_conditions(tmpdir) -> None: ] -def test_function_calls_from_with_clause(tmpdir) -> None: +def test_function_calls_from_with_clause(tmpdir): # language=python content = """ # with clause @@ -255,5 +255,5 @@ def test_function_calls_from_with_clause(tmpdir) -> None: @pytest.mark.skip(reason="Ellen: why is this test empty?") -def test_function_calls_from_function_calls(tmpdir) -> None: +def test_function_calls_from_function_calls(tmpdir): pass diff --git a/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py b/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py index 2725ffbfc..918d7d171 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py +++ b/tests/unit/codegen/sdk/python/expressions/test_binary_expression.py @@ -9,7 +9,7 @@ from codegen.sdk.python import PyFile -def test_all_binary_expression_types(tmpdir) -> None: +def test_all_binary_expression_types(tmpdir): # language=python content = """ a = 1 + 2 @@ -133,7 +133,7 @@ def test_all_binary_expression_types(tmpdir) -> None: assert file.get_global_var("w").value.operator.source == "in" -def test_chained_binary_expressions(tmpdir) -> None: +def test_chained_binary_expressions(tmpdir): # language=python content = """ a = 1 + 2 - 3 * 4 / 5 % 6 ** 7 // 8 # binary operators @@ -157,7 +157,7 @@ def test_chained_binary_expressions(tmpdir) -> None: @pytest.mark.skip(reason="CG-8883: Parenthesized expressions not implemented yet") -def test_chained_multiline_binary_expressions_using_parenthesis(tmpdir) -> None: +def test_chained_multiline_binary_expressions_using_parenthesis(tmpdir): # language=python content = """ a = (1 + 2 - 3 * 4 @@ -185,7 +185,7 @@ def test_chained_multiline_binary_expressions_using_parenthesis(tmpdir) -> None: assert [x.source for x in c.operators] == ["and", "or", "and", "or"] -def test_chained_multiline_binary_expressions_using_backslash(tmpdir) -> None: +def test_chained_multiline_binary_expressions_using_backslash(tmpdir): # language=python content = """ a = 1 + 2 - 3 * 4 \ @@ -214,7 +214,7 @@ def test_chained_multiline_binary_expressions_using_backslash(tmpdir) -> None: @pytest.mark.skip(reason="CG-8886: Mixed expression groups not implemented yet") -def test_chained_mixed_binary_expressions(tmpdir) -> None: +def test_chained_mixed_binary_expressions(tmpdir): # language=python content = """ a = 1 + 2 == True != False or True and False * 12 @@ -238,7 +238,7 @@ def test_chained_mixed_binary_expressions(tmpdir) -> None: @pytest.mark.skip(reason="CG-8883: Parenthesized expressions not implemented yet") -def test_chained_mixed_multiline_binary_expressions_with_parenthesis(tmpdir) -> None: +def test_chained_mixed_multiline_binary_expressions_with_parenthesis(tmpdir): # language=python content = """ a = (1 + 2 == True @@ -253,7 +253,7 @@ def test_chained_mixed_multiline_binary_expressions_with_parenthesis(tmpdir) -> @pytest.mark.skip(reason="CG-8886: Mixed expression groups not implemented yet") -def test_chained_mixed_multiline_binary_expressions_with_backslash(tmpdir) -> None: +def test_chained_mixed_multiline_binary_expressions_with_backslash(tmpdir): # language=python content = """ a = 1 + 2 == True \ diff --git a/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py b/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py index d3aef419c..1e63e0fd1 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py +++ b/tests/unit/codegen/sdk/python/expressions/test_binary_reduce_condition.py @@ -7,7 +7,7 @@ from codegen.sdk.python.file import PyFile -def test_reduce_binary_simple(tmpdir) -> None: +def test_reduce_binary_simple(tmpdir): # language=python content = """ def foo(): @@ -31,7 +31,7 @@ def foo(): ) -def test_reduce_binary_complex_condition(tmpdir) -> None: +def test_reduce_binary_complex_condition(tmpdir): # language=python content = """ def bar(): @@ -58,7 +58,7 @@ def bar(): ) -def test_reduce_negation_condition(tmpdir) -> None: +def test_reduce_negation_condition(tmpdir): # language=python content = """ def baz(): @@ -84,7 +84,7 @@ def baz(): ) -def test_reduce_binary_with_string(tmpdir) -> None: +def test_reduce_binary_with_string(tmpdir): # language=python content = """ def qux(): @@ -108,7 +108,7 @@ def qux(): ) -def test_reduce_complex_condition_with_string(tmpdir) -> None: +def test_reduce_complex_condition_with_string(tmpdir): # language=python content = """ def quux(): diff --git a/tests/unit/codegen/sdk/python/expressions/test_boolean.py b/tests/unit/codegen/sdk/python/expressions/test_boolean.py index cf3777914..51ac48ecb 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_boolean.py +++ b/tests/unit/codegen/sdk/python/expressions/test_boolean.py @@ -5,7 +5,7 @@ from codegen.sdk.python.assignment import PyAssignment -def test_boolean_parse(tmpdir) -> None: +def test_boolean_parse(tmpdir): # language=python content = """ a = True diff --git a/tests/unit/codegen/sdk/python/expressions/test_number.py b/tests/unit/codegen/sdk/python/expressions/test_number.py index 30cc9cf5a..1452f1477 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_number.py +++ b/tests/unit/codegen/sdk/python/expressions/test_number.py @@ -3,7 +3,7 @@ from codegen.sdk.core.expressions.number import Number -def test_number_parse(tmpdir) -> None: +def test_number_parse(tmpdir): # language=python content = """ a = 1 diff --git a/tests/unit/codegen/sdk/python/expressions/test_type.py b/tests/unit/codegen/sdk/python/expressions/test_type.py index a90325d16..22cd7f8f5 100644 --- a/tests/unit/codegen/sdk/python/expressions/test_type.py +++ b/tests/unit/codegen/sdk/python/expressions/test_type.py @@ -9,7 +9,7 @@ from codegen.sdk.python import PyAssignment, PyClass, PyFunction -def test_type_basic(tmpdir) -> None: +def test_type_basic(tmpdir): file = "test.py" # language=python content = """ @@ -35,7 +35,7 @@ def foo(a: str): ) -def test_type_generic(tmpdir) -> None: +def test_type_generic(tmpdir): file = "test.py" # language=python content = """ @@ -63,7 +63,7 @@ def foo(a: tuple[int, int, str]): ) -def test_type_union(tmpdir) -> None: +def test_type_union(tmpdir): file = "test.py" # language=python content = """ @@ -90,7 +90,7 @@ def foo(a: int | None | str): ) -def test_type_multi_file(tmpdir) -> None: +def test_type_multi_file(tmpdir): file2 = "test2.py" # language=python content2 = """ diff --git a/tests/unit/codegen/sdk/python/function/test_function_async.py b/tests/unit/codegen/sdk/python/function/test_function_async.py index 79bceadc0..796b323b7 100644 --- a/tests/unit/codegen/sdk/python/function/test_function_async.py +++ b/tests/unit/codegen/sdk/python/function/test_function_async.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_function_is_async_basic(tmpdir) -> None: +def test_function_is_async_basic(tmpdir): # language=python content = """ def foo(): @@ -56,7 +56,7 @@ async def qux(self): ) -def test_function_is_async_extended(tmpdir) -> None: +def test_function_is_async_extended(tmpdir): # language=python content = """ @my_decorator diff --git a/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py b/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py index fd3d817d8..c31f55f22 100644 --- a/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py +++ b/tests/unit/codegen/sdk/python/import_resolution/test_is_dynamic.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_py_import_is_dynamic_in_function(tmpdir) -> None: +def test_py_import_is_dynamic_in_function(tmpdir): # language=python content = """ def my_function(): @@ -23,7 +23,7 @@ def my_function(): assert not imports[2].is_dynamic # import static_import -def test_py_import_is_dynamic_in_if_block(tmpdir) -> None: +def test_py_import_is_dynamic_in_if_block(tmpdir): # language=python content = """ import top_level # Static import @@ -41,7 +41,7 @@ def test_py_import_is_dynamic_in_if_block(tmpdir) -> None: assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_try_except(tmpdir) -> None: +def test_py_import_is_dynamic_in_try_except(tmpdir): # language=python content = """ import static_first # Static import @@ -61,7 +61,7 @@ def test_py_import_is_dynamic_in_try_except(tmpdir) -> None: assert imports[2].is_dynamic # from x.y import z -def test_py_import_is_dynamic_in_with_block(tmpdir) -> None: +def test_py_import_is_dynamic_in_with_block(tmpdir): # language=python content = """ import static_import # Static import @@ -79,7 +79,7 @@ def test_py_import_is_dynamic_in_with_block(tmpdir) -> None: assert imports[2].is_dynamic # from a.b import c -def test_py_import_is_dynamic_in_class_method(tmpdir) -> None: +def test_py_import_is_dynamic_in_class_method(tmpdir): # language=python content = """ import static_import # Static import @@ -103,7 +103,7 @@ def class_method(cls): assert imports[3].is_dynamic # another_dynamic import -def test_py_import_is_dynamic_in_nested_function(tmpdir) -> None: +def test_py_import_is_dynamic_in_nested_function(tmpdir): # language=python content = """ import static_import # Static import @@ -125,7 +125,7 @@ def inner_function(): assert imports[3].is_dynamic # from x import y -def test_py_import_is_dynamic_in_else_clause(tmpdir) -> None: +def test_py_import_is_dynamic_in_else_clause(tmpdir): # language=python content = """ import static_import # Static import @@ -145,7 +145,7 @@ def test_py_import_is_dynamic_in_else_clause(tmpdir) -> None: assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_except_clause(tmpdir) -> None: +def test_py_import_is_dynamic_in_except_clause(tmpdir): # language=python content = """ import static_import # Static import @@ -165,7 +165,7 @@ def test_py_import_is_dynamic_in_except_clause(tmpdir) -> None: assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_finally_clause(tmpdir) -> None: +def test_py_import_is_dynamic_in_finally_clause(tmpdir): # language=python content = """ import static_import # Static import @@ -187,7 +187,7 @@ def test_py_import_is_dynamic_in_finally_clause(tmpdir) -> None: assert imports[2].is_dynamic # from x import y -def test_py_import_is_dynamic_in_while_statement(tmpdir) -> None: +def test_py_import_is_dynamic_in_while_statement(tmpdir): # language=python content = """ import static_import # Static import @@ -205,7 +205,7 @@ def test_py_import_is_dynamic_in_while_statement(tmpdir) -> None: assert imports[2].is_dynamic # from a import b -def test_py_import_is_dynamic_in_match_case(tmpdir) -> None: +def test_py_import_is_dynamic_in_match_case(tmpdir): # language=python content = """ import static_import # Static import diff --git a/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py b/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py index d8141f0ea..d1eaecd13 100644 --- a/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py +++ b/tests/unit/codegen/sdk/python/statements/if_block_statement/test_if_block_reduce_block.py @@ -9,7 +9,7 @@ from codegen.sdk.python import PyFile -def test_reduce_condition_to_true_elif(tmpdir) -> None: +def test_reduce_condition_to_true_elif(tmpdir): # language=python content = """ def foo(): @@ -41,7 +41,7 @@ def foo(): ) -def test_reduce_condition_to_false_elif(tmpdir) -> None: +def test_reduce_condition_to_false_elif(tmpdir): # language=python content = """ def foo(): @@ -71,7 +71,7 @@ def foo(): ) -def test_reduce_condition_to_true_else(tmpdir) -> None: +def test_reduce_condition_to_true_else(tmpdir): # language=python content = """ def foo(): @@ -97,7 +97,7 @@ def foo(): ) -def test_reduce_condition_to_false_else(tmpdir) -> None: +def test_reduce_condition_to_false_else(tmpdir): # language=python content = """ def foo(): @@ -123,7 +123,7 @@ def foo(): ) -def test_reduce_condition_multiple_if_blocks(tmpdir) -> None: +def test_reduce_condition_multiple_if_blocks(tmpdir): # language=python content = """ def foo(): @@ -155,7 +155,7 @@ def foo(): ) -def test_reduce_condition_nested_if(tmpdir) -> None: +def test_reduce_condition_nested_if(tmpdir): # language=python content = """ class MyClass: @@ -198,7 +198,7 @@ def foo(self): ) -def test_reduce_condition_else_if_to_true(tmpdir) -> None: +def test_reduce_condition_else_if_to_true(tmpdir): # language=python content = """ def foo(): @@ -234,7 +234,7 @@ def foo(): ) -def test_reduce_condition_else_if_to_false(tmpdir) -> None: +def test_reduce_condition_else_if_to_false(tmpdir): # language=python content = """ def foo(): @@ -268,7 +268,7 @@ def foo(): ) -def test_reduce_condition_second_else_if_to_true(tmpdir) -> None: +def test_reduce_condition_second_else_if_to_true(tmpdir): # language=python content = """ def foo(): @@ -300,7 +300,7 @@ def foo(): ) -def test_reduce_condition_second_else_if_to_false(tmpdir) -> None: +def test_reduce_condition_second_else_if_to_false(tmpdir): # language=python content = """ def foo(): @@ -332,7 +332,7 @@ def foo(): ) -def test_reduce_condition_else_statement_raises(tmpdir) -> None: +def test_reduce_condition_else_statement_raises(tmpdir): # language=python content = """ def foo(): @@ -351,7 +351,7 @@ def foo(): else_block.reduce_condition(True) -def test_reduce_condition_to_true_single_if(tmpdir) -> None: +def test_reduce_condition_to_true_single_if(tmpdir): # language=python content = """ def foo(): @@ -375,7 +375,7 @@ def foo(): ) -def test_reduce_condition_to_false_single_if(tmpdir) -> None: +def test_reduce_condition_to_false_single_if(tmpdir): # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py b/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py index 45b129002..db139e11e 100644 --- a/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py +++ b/tests/unit/codegen/sdk/python/statements/with_statement/test_with_statement_properties.py @@ -8,7 +8,7 @@ from codegen.sdk.python import PyFile -def test_with_statement_single_var(tmpdir) -> None: +def test_with_statement_single_var(tmpdir): # language=python content = """ def foo(): @@ -38,7 +38,7 @@ def foo(): ) -def test_with_statement_aliased_var(tmpdir) -> None: +def test_with_statement_aliased_var(tmpdir): # language=python content = """ def foo(): @@ -67,7 +67,7 @@ def foo(): ) -def test_with_statement_multiple_vars(tmpdir) -> None: +def test_with_statement_multiple_vars(tmpdir): # language=python content = """ def foo(): @@ -96,7 +96,7 @@ def foo(): ) -def test_with_statement_multiline_vars(tmpdir) -> None: +def test_with_statement_multiline_vars(tmpdir): # language=python content = """ def foo(): @@ -137,7 +137,7 @@ def foo(): ) -def test_with_statement_function_call(tmpdir) -> None: +def test_with_statement_function_call(tmpdir): # language=python content = """ def foo(): diff --git a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py index e0e63548d..35e7622be 100644 --- a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py +++ b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_indent.py @@ -3,7 +3,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_indent_once_to_left(tmpdir) -> None: +def test_indent_once_to_left(tmpdir): # language=typescript content = """ function foo(): number { @@ -30,7 +30,7 @@ def test_indent_once_to_left(tmpdir) -> None: ) -def test_indent_left_exceed_limit(tmpdir) -> None: +def test_indent_left_exceed_limit(tmpdir): # language=typescript content = """ function foo(): number { @@ -57,7 +57,7 @@ def test_indent_left_exceed_limit(tmpdir) -> None: ) -def test_indent_right_once(tmpdir) -> None: +def test_indent_right_once(tmpdir): # language=typescript content = """ function foo(): number { @@ -84,7 +84,7 @@ def test_indent_right_once(tmpdir) -> None: ) -def test_indent_right_multiple(tmpdir) -> None: +def test_indent_right_multiple(tmpdir): # language=typescript content = """ function foo(): number { @@ -111,7 +111,7 @@ def test_indent_right_multiple(tmpdir) -> None: ) -def test_indent_zero(tmpdir) -> None: +def test_indent_zero(tmpdir): # language=typescript content = """ function foo(): number { @@ -128,7 +128,7 @@ def test_indent_zero(tmpdir) -> None: assert file.content == content -def test_indent_nested_code_blocks(tmpdir) -> None: +def test_indent_nested_code_blocks(tmpdir): # language=typescript content = """ function foo(): number { @@ -201,7 +201,7 @@ def test_indent_nested_code_blocks(tmpdir) -> None: ) -def test_indent_only_nested_block(tmpdir) -> None: +def test_indent_only_nested_block(tmpdir): # language=typescript content = """ function foo(a: boolean, b: any, c: any, d: boolean): void { diff --git a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py index e37d109dd..0ebccc5b5 100644 --- a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py +++ b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_unwrap.py @@ -8,7 +8,7 @@ from codegen.sdk.typescript.file import TSFile -def test_unwrap_flat_statements(tmpdir) -> None: +def test_unwrap_flat_statements(tmpdir): # language=typescript content = """ function foo(): void { @@ -40,7 +40,7 @@ def test_unwrap_flat_statements(tmpdir) -> None: ) -def test_unwrap_nested_statements(tmpdir) -> None: +def test_unwrap_nested_statements(tmpdir): # language=typescript content = """ function foo(): void { @@ -83,7 +83,7 @@ def test_unwrap_nested_statements(tmpdir) -> None: ) -def test_unwrap_sandwiched_statements(tmpdir) -> None: +def test_unwrap_sandwiched_statements(tmpdir): # language=typescript content = """ function foo(): void { @@ -124,7 +124,7 @@ def test_unwrap_sandwiched_statements(tmpdir) -> None: ) -def test_unwrap_multiline_wrapper(tmpdir) -> None: +def test_unwrap_multiline_wrapper(tmpdir): # language=typescript content = """ function foo(): void { diff --git a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py index 2b3c805bf..0a52dece6 100644 --- a/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py +++ b/tests/unit/codegen/sdk/typescript/detached_symbols/code_block/test_code_block_wrap.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_wrap_with_if_statement(tmpdir) -> None: +def test_wrap_with_if_statement(tmpdir): # language=typescript jsx content = """ function funcA(a) { diff --git a/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py b/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py index ed5dc6a07..48bc5a502 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py +++ b/tests/unit/codegen/sdk/typescript/export/test_export_aliased.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_export_aliased(tmpdir) -> None: +def test_export_aliased(tmpdir): # language=typescript content = """ function foo() {} @@ -31,7 +31,7 @@ def test_export_aliased(tmpdir) -> None: assert fuzz_export.resolved_symbol == file.get_function("fuzz") -def test_export_aliased_multiple(tmpdir) -> None: +def test_export_aliased_multiple(tmpdir): # language=typescript content = """ function foo() {} @@ -60,7 +60,7 @@ def test_export_aliased_multiple(tmpdir) -> None: assert baz_export.resolved_symbol == file.get_function("baz") -def test_export_aliased_default(tmpdir) -> None: +def test_export_aliased_default(tmpdir): # language=typescript content = """ function foo() {} diff --git a/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py b/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py index 113a591ef..c9ae8a410 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py +++ b/tests/unit/codegen/sdk/typescript/export/test_export_export_statement.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_export_export_statement(tmpdir) -> None: +def test_export_export_statement(tmpdir): # language=typescript content = """ function foo() {} @@ -29,7 +29,7 @@ def test_export_export_statement(tmpdir) -> None: ] -def test_remove_export(tmpdir) -> None: +def test_remove_export(tmpdir): # language=typescript content = """ function foo() {} @@ -55,7 +55,7 @@ def test_remove_export(tmpdir) -> None: ) -def test_remove_all_exports(tmpdir) -> None: +def test_remove_all_exports(tmpdir): # language=typescript content = """ function foo() {} @@ -77,7 +77,7 @@ def test_remove_all_exports(tmpdir) -> None: ) -def test_add_export(tmpdir) -> None: +def test_add_export(tmpdir): # language=typescript content = """ function foo() {} @@ -101,7 +101,7 @@ def test_add_export(tmpdir) -> None: ) -def test_insert_export_at_start(tmpdir) -> None: +def test_insert_export_at_start(tmpdir): # language=typescript content = """ function foo() {} @@ -125,7 +125,7 @@ def test_insert_export_at_start(tmpdir) -> None: ) -def test_remove_middle_export(tmpdir) -> None: +def test_remove_middle_export(tmpdir): # language=typescript content = """ function foo() {} @@ -150,7 +150,7 @@ def test_remove_middle_export(tmpdir) -> None: ) -def test_remove_inline_export(tmpdir) -> None: +def test_remove_inline_export(tmpdir): # language=typescript content = """ export function foo() {} @@ -172,7 +172,7 @@ def test_remove_inline_export(tmpdir) -> None: ) -def test_add_remove_reexport_inline(tmpdir) -> None: +def test_add_remove_reexport_inline(tmpdir): # language=typescript content = """ export { foo, bar } from './other'; @@ -198,7 +198,7 @@ def test_add_remove_reexport_inline(tmpdir) -> None: ) -def test_remove_namespace_export(tmpdir) -> None: +def test_remove_namespace_export(tmpdir): # language=typescript content = """ export namespace Foo { @@ -224,7 +224,7 @@ def test_remove_namespace_export(tmpdir) -> None: ) -def test_remove_add_wildcard_export(tmpdir) -> None: +def test_remove_add_wildcard_export(tmpdir): # language=typescript content = """ export * from './foo'; @@ -245,7 +245,7 @@ def test_remove_add_wildcard_export(tmpdir) -> None: ) -def test_remove_all_exports_multiline(tmpdir) -> None: +def test_remove_all_exports_multiline(tmpdir): # language=typescript content = """ function foo() {} diff --git a/tests/unit/codegen/sdk/typescript/export/test_external_export.py b/tests/unit/codegen/sdk/typescript/export/test_external_export.py index 84e74d0ac..56c169aeb 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_external_export.py +++ b/tests/unit/codegen/sdk/typescript/export/test_external_export.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_is_external_export_true(tmpdir) -> None: +def test_is_external_export_true(tmpdir): # language=typescript content = """ export { default as React } from "react"; @@ -22,7 +22,7 @@ def test_is_external_export_true(tmpdir) -> None: assert file.exports[0].is_external_export is True -def test_is_external_export_false(tmpdir) -> None: +def test_is_external_export_false(tmpdir): # language=typescript content = """ export { foo } from "./foo"; @@ -40,7 +40,7 @@ def test_is_external_export_false(tmpdir) -> None: assert file.exports[0].is_external_export is False -def test_multiple_external_exports(tmpdir) -> None: +def test_multiple_external_exports(tmpdir): # language=typescript content = """ export { default as React } from "react"; @@ -57,7 +57,7 @@ def test_multiple_external_exports(tmpdir) -> None: assert all(export.is_external_export for export in file.exports) -def test_mixed_internal_external_exports(tmpdir) -> None: +def test_mixed_internal_external_exports(tmpdir): # language=typescript content = """ export { default as lodash } from "lodash"; @@ -80,7 +80,7 @@ def test_mixed_internal_external_exports(tmpdir) -> None: assert file.exports[2].is_external_export is False -def test_nested_reexports(tmpdir) -> None: +def test_nested_reexports(tmpdir): # language=typescript with get_codebase_session( tmpdir=tmpdir, @@ -106,7 +106,7 @@ def test_nested_reexports(tmpdir) -> None: assert services_file.exports[0].is_external_export is False -def test_wildcard_exports(tmpdir) -> None: +def test_wildcard_exports(tmpdir): # language=typescript with get_codebase_session( tmpdir=tmpdir, diff --git a/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py b/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py index ecd60e762..e035e2030 100644 --- a/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py +++ b/tests/unit/codegen/sdk/typescript/export/test_get_reexported_exports.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_get_reexported_exports(tmpdir) -> None: +def test_get_reexported_exports(tmpdir): # language=typescript with get_codebase_session( tmpdir=tmpdir, @@ -42,7 +42,7 @@ def test_get_reexported_exports(tmpdir) -> None: assert len(reexports) == 0 -def test_get_reexported_export_with_external_module_on_export(tmpdir) -> None: +def test_get_reexported_export_with_external_module_on_export(tmpdir): # language=typescript with get_codebase_session( tmpdir=tmpdir, @@ -70,7 +70,7 @@ def test_get_reexported_export_with_external_module_on_export(tmpdir) -> None: assert len(reexports) == 2 -def test_get_reexported_export_with_alias(tmpdir) -> None: +def test_get_reexported_export_with_alias(tmpdir): # language=typescript with get_codebase_session( tmpdir=tmpdir, diff --git a/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py b/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py index 608ba5f88..fac383111 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py +++ b/tests/unit/codegen/sdk/typescript/expressions/ternary_expression/test_ternary_reduce_condition.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_reduce_ternary_condition_to_true(tmpdir) -> None: +def test_reduce_ternary_condition_to_true(tmpdir): # language=typescript content = """ function foo(): void { @@ -32,7 +32,7 @@ def test_reduce_ternary_condition_to_true(tmpdir) -> None: ) -def test_reduce_ternary_condition_to_false(tmpdir) -> None: +def test_reduce_ternary_condition_to_false(tmpdir): # language=typescript content = """ function foo(): void { @@ -57,7 +57,7 @@ def test_reduce_ternary_condition_to_false(tmpdir) -> None: ) -def test_reduce_nested_ternary_condition_to_true_and_false(tmpdir) -> None: +def test_reduce_nested_ternary_condition_to_true_and_false(tmpdir): # language=typescript content = """ function foo(): void { @@ -84,7 +84,7 @@ def test_reduce_nested_ternary_condition_to_true_and_false(tmpdir) -> None: ) -def test_reduce_nested_ternary_condition_outer_false(tmpdir) -> None: +def test_reduce_nested_ternary_condition_outer_false(tmpdir): # language=typescript content = """ function foo(): void { @@ -109,7 +109,7 @@ def test_reduce_nested_ternary_condition_outer_false(tmpdir) -> None: ) -def test_reduce_multiple_ternary_conditions(tmpdir) -> None: +def test_reduce_multiple_ternary_conditions(tmpdir): # language=typescript content = """ function foo(): void { @@ -138,7 +138,7 @@ def test_reduce_multiple_ternary_conditions(tmpdir) -> None: ) -def test_reduce_ternary_condition_with_function_call(tmpdir) -> None: +def test_reduce_ternary_condition_with_function_call(tmpdir): # language=typescript content = """ function foo(): void { @@ -163,7 +163,7 @@ def test_reduce_ternary_condition_with_function_call(tmpdir) -> None: ) -def test_reduce_ternary_condition_with_dict(tmpdir) -> None: +def test_reduce_ternary_condition_with_dict(tmpdir): # language=typescript jsx # language=typescript content = """ @@ -198,7 +198,7 @@ def test_reduce_ternary_condition_with_dict(tmpdir) -> None: ) -def test_reduce_ternary_condition_with_dict_complex(tmpdir) -> None: +def test_reduce_ternary_condition_with_dict_complex(tmpdir): # language=typescript jsx # language=typescript content = """ @@ -234,7 +234,7 @@ def test_reduce_ternary_condition_with_dict_complex(tmpdir) -> None: ) -def test_reduce_ternary_condition_with_dict_trailing_comma(tmpdir) -> None: +def test_reduce_ternary_condition_with_dict_trailing_comma(tmpdir): # language=typescript content = """ function foo(): { a: number } { diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py b/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py index 4d862abfa..9d4f26f75 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_binary_expression.py @@ -8,7 +8,7 @@ from codegen.sdk.typescript.file import TSFile -def test_binary_expressions(tmpdir) -> None: +def test_binary_expressions(tmpdir): # language=typescript content = """ let a: number = 1 + 2; @@ -127,7 +127,7 @@ def test_binary_expressions(tmpdir) -> None: assert file.get_global_var("v").value.operator.source == "in" -def test_chained_binary_expressions(tmpdir) -> None: +def test_chained_binary_expressions(tmpdir): # language=typescript content = """ // binary operators diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py b/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py index a99a21bd7..b21ef842b 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_binary_reduce_condition.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_reduce_binary_simple(tmpdir) -> None: +def test_reduce_binary_simple(tmpdir): # language=typescript content = """ function foo(): void { @@ -33,7 +33,7 @@ def test_reduce_binary_simple(tmpdir) -> None: ) -def test_reduce_binary_object(tmpdir) -> None: +def test_reduce_binary_object(tmpdir): # language=typescript content = """ function foo(): void { @@ -62,7 +62,7 @@ def test_reduce_binary_object(tmpdir) -> None: ) -def test_reduce_binary_complex_condition(tmpdir) -> None: +def test_reduce_binary_complex_condition(tmpdir): # language=typescript content = """ function bar(): void { @@ -91,7 +91,7 @@ def test_reduce_binary_complex_condition(tmpdir) -> None: ) -def test_reduce_negation_condition(tmpdir) -> None: +def test_reduce_negation_condition(tmpdir): # language=typescript content = """ function baz(): void { @@ -119,7 +119,7 @@ def test_reduce_negation_condition(tmpdir) -> None: ) -def test_reduce_jsx_element(tmpdir) -> None: +def test_reduce_jsx_element(tmpdir): # language=typescript jsx content = """ const MyComponent: React.FC = () => { @@ -154,7 +154,7 @@ def test_reduce_jsx_element(tmpdir) -> None: ) -def test_reduce_jsx_element_keep(tmpdir) -> None: +def test_reduce_jsx_element_keep(tmpdir): # language=typescript jsx content = """ const MyComponent: React.FC = () => { @@ -188,7 +188,7 @@ def test_reduce_jsx_element_keep(tmpdir) -> None: ) -def test_reduce_complex_condition_with_JSX(tmpdir) -> None: +def test_reduce_complex_condition_with_JSX(tmpdir): # language=typescript jsx content = """ const AnotherComponent: React.FC = () => { diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py b/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py index 5e2b5e668..7ce20bc67 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_boolean.py @@ -5,7 +5,7 @@ from codegen.sdk.typescript.assignment import TSAssignment -def test_boolean_parse(tmpdir) -> None: +def test_boolean_parse(tmpdir): # language=typescript content = """ const a = true; diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_dict.py b/tests/unit/codegen/sdk/typescript/expressions/test_dict.py index b9143da32..4478340dc 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_dict.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_dict.py @@ -9,7 +9,7 @@ from codegen.sdk.typescript.function import TSFunction -def test_dict_basic(tmpdir) -> None: +def test_dict_basic(tmpdir): file = "test.ts" # language=typescript content = """ @@ -36,7 +36,7 @@ def test_dict_basic(tmpdir) -> None: ) -def test_dict_multiline(tmpdir) -> None: +def test_dict_multiline(tmpdir): file = "test.ts" # language=typescript content = """ @@ -73,7 +73,7 @@ def test_dict_multiline(tmpdir) -> None: ) -def test_dict_insert(tmpdir) -> None: +def test_dict_insert(tmpdir): file = "test.ts" # language=typescript content = """ @@ -98,7 +98,7 @@ def test_dict_insert(tmpdir) -> None: @pytest.mark.parametrize("removes,inserts", cases, ids=[f"{removes=}-{inserts=}" for removes, inserts in cases]) -def test_dict_interleaved(tmpdir, removes, inserts) -> None: +def test_dict_interleaved(tmpdir, removes, inserts): ref_dict = {str(-1 + -i): -(i**2) for i in range(removes)} file = "test.ts" content = f""" @@ -124,7 +124,7 @@ def test_dict_interleaved(tmpdir, removes, inserts) -> None: @pytest.mark.parametrize("removes,inserts", cases, ids=[f"{removes=}-{inserts=}" for removes, inserts in cases]) -def test_dict_removes_first(tmpdir, removes, inserts) -> None: +def test_dict_removes_first(tmpdir, removes, inserts): ref_dict = {str(-1 + -i): -(i**2) for i in range(removes)} file = "test.ts" content = f""" @@ -149,7 +149,7 @@ def test_dict_removes_first(tmpdir, removes, inserts) -> None: @pytest.mark.parametrize("removes,inserts", cases, ids=[f"{removes=}-{inserts=}" for removes, inserts in cases]) -def test_dict_inserts_first(tmpdir, removes, inserts) -> None: +def test_dict_inserts_first(tmpdir, removes, inserts): ref_dict = {str(-1 + -i): -(i**2) for i in range(removes)} file = "test.ts" content = f""" @@ -174,7 +174,7 @@ def test_dict_inserts_first(tmpdir, removes, inserts) -> None: @pytest.mark.parametrize("existing,inserts", cases, ids=[f"{existing=}-{inserts=}" for existing, inserts in cases]) -def test_dict_append_existing(tmpdir, existing, inserts) -> None: +def test_dict_append_existing(tmpdir, existing, inserts): ref_dict = {str(-1 + -i): -(i**2) for i in range(existing)} file = "test.ts" content = f""" @@ -196,7 +196,7 @@ def test_dict_append_existing(tmpdir, existing, inserts) -> None: @pytest.mark.parametrize("existing", list(range(4)), ids=[f"existing={existing}" for existing in range(4)]) -def test_dict_set_existing(tmpdir, existing) -> None: +def test_dict_set_existing(tmpdir, existing): ref_dict = {str(-1 + -i): -(i**2) for i in range(existing)} file = "test.ts" content = f""" @@ -218,7 +218,7 @@ def test_dict_set_existing(tmpdir, existing) -> None: @pytest.mark.parametrize("existing,inserts", cases, ids=[f"existing={existing + 1}-{inserts=}" for existing, inserts in cases]) -def test_dict_set_existing_same(tmpdir, existing, inserts) -> None: +def test_dict_set_existing_same(tmpdir, existing, inserts): ref_dict = {str(-1 + -i): -(i**2) for i in range(existing)} file = "test.ts" content = f""" @@ -239,7 +239,7 @@ def test_dict_set_existing_same(tmpdir, existing, inserts) -> None: ) -def test_dict_empty(tmpdir) -> None: +def test_dict_empty(tmpdir): file = "test.ts" # language=typescript content = """ @@ -263,7 +263,7 @@ def test_dict_empty(tmpdir) -> None: ) -def test_dict_remove_insert(tmpdir) -> None: +def test_dict_remove_insert(tmpdir): file = "test.ts" # language=typescript content = """ @@ -286,7 +286,7 @@ def test_dict_remove_insert(tmpdir) -> None: ) -def test_dict_shorthand_remove_insert(tmpdir) -> None: +def test_dict_shorthand_remove_insert(tmpdir): file = "test.ts" # language=typescript content = """ @@ -309,7 +309,7 @@ def test_dict_shorthand_remove_insert(tmpdir) -> None: ) -def test_dict_edit(tmpdir) -> None: +def test_dict_edit(tmpdir): file = "test.ts" # language=typescript content = """ @@ -330,7 +330,7 @@ def test_dict_edit(tmpdir) -> None: ) -def test_dict_edit_shorthand(tmpdir) -> None: +def test_dict_edit_shorthand(tmpdir): file = "test.ts" # language=typescript content = """ @@ -351,7 +351,7 @@ def test_dict_edit_shorthand(tmpdir) -> None: ) -def test_dict_edit_not_shorthand(tmpdir) -> None: +def test_dict_edit_not_shorthand(tmpdir): file = "test.ts" # language=typescript content = """ @@ -372,7 +372,7 @@ def test_dict_edit_not_shorthand(tmpdir) -> None: ) -def test_dict_clear(tmpdir) -> None: +def test_dict_clear(tmpdir): file = "test.ts" # language=typescript content = """ @@ -394,7 +394,7 @@ def test_dict_clear(tmpdir) -> None: @pytest.mark.xfail(reason="Not implemented Yet") -def test_dict_obj(tmpdir) -> None: +def test_dict_obj(tmpdir): file = "test.ts" # language=typescript content = """ @@ -421,7 +421,7 @@ def test_dict_obj(tmpdir) -> None: ) -def test_dict_shorthand(tmpdir) -> None: +def test_dict_shorthand(tmpdir): file = "test.ts" # language=typescript content = """ @@ -448,7 +448,7 @@ def test_dict_shorthand(tmpdir) -> None: ) -def test_shorthand_multiline(tmpdir) -> None: +def test_shorthand_multiline(tmpdir): file = "test.ts" # language=typescript content = """ @@ -485,7 +485,7 @@ def test_shorthand_multiline(tmpdir) -> None: ) -def test_convert_shorthand(tmpdir) -> None: +def test_convert_shorthand(tmpdir): file = "test.ts" # language=typescript content = """ @@ -509,7 +509,7 @@ def test_convert_shorthand(tmpdir) -> None: ) -def test_dict_shorthand_insert(tmpdir) -> None: +def test_dict_shorthand_insert(tmpdir): file = "test.ts" # language=typescript content = """ @@ -530,7 +530,7 @@ def test_dict_shorthand_insert(tmpdir) -> None: ) -def test_dict_function_values(tmpdir) -> None: +def test_dict_function_values(tmpdir): # language=typescript content = """ export const mapper = { @@ -559,7 +559,7 @@ def test_dict_function_values(tmpdir) -> None: assert len(list(d.items())) == 3 assert list(d.keys()) == ["method1", "method2", "method3"] assert all(isinstance(v, TSFunction) for v in list(d.values())) - for func_def in d.values(): + for key, func_def in d.items(): func_def.insert_before("async ", newline=False, extended=False) func_def.set_return_type(f"Promise<{func_def.return_type.source}>") @@ -588,7 +588,7 @@ def test_dict_function_values(tmpdir) -> None: ) -def test_dict_usage(tmpdir) -> None: +def test_dict_usage(tmpdir): file = "test.ts" # language=typescript content = """ @@ -604,7 +604,7 @@ def test_dict_usage(tmpdir) -> None: assert {*foo.symbol_usages} == {obj} -def test_dict_usage_shorthand(tmpdir) -> None: +def test_dict_usage_shorthand(tmpdir): file = "test.ts" # language=typescript content = """ @@ -620,7 +620,7 @@ def test_dict_usage_shorthand(tmpdir) -> None: assert {*foo.symbol_usages} == {obj} -def test_dict_usage_spread(tmpdir) -> None: +def test_dict_usage_spread(tmpdir): file = "test.ts" # language=typescript jsx # language=typescript diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_expression.py b/tests/unit/codegen/sdk/typescript/expressions/test_expression.py index 890a6c850..3e66e8711 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_expression.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_expression.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_function_calls_from_function_call(tmpdir) -> None: +def test_function_calls_from_function_call(tmpdir): # language=typescript content = """ describe("LoadManager test", () => { @@ -19,7 +19,7 @@ def test_function_calls_from_function_call(tmpdir) -> None: assert len(func_call) == 6 -def test_remove_parenthesized(tmpdir) -> None: +def test_remove_parenthesized(tmpdir): # language=typescript content = """ const a = (b) || c; @@ -37,7 +37,7 @@ def test_remove_parenthesized(tmpdir) -> None: ) -def test_remove_tsx(tmpdir) -> None: +def test_remove_tsx(tmpdir): # language=typescript jsx content = """ const element =

Hello, {name}

; diff --git a/tests/unit/codegen/sdk/typescript/expressions/test_number.py b/tests/unit/codegen/sdk/typescript/expressions/test_number.py index 82820eb99..a191ff95b 100644 --- a/tests/unit/codegen/sdk/typescript/expressions/test_number.py +++ b/tests/unit/codegen/sdk/typescript/expressions/test_number.py @@ -4,7 +4,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_number_parse(tmpdir) -> None: +def test_number_parse(tmpdir): # language=typescript content = """ const a = 1; diff --git a/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py b/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py index a8117fcbb..adaa00922 100644 --- a/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py +++ b/tests/unit/codegen/sdk/typescript/file/test_file_export_statements.py @@ -20,7 +20,7 @@ def _get_file(content: str): @pytest.fixture def export_check(ts_file): - def _export_check(*sources) -> None: + def _export_check(*sources): file = ts_file("\n".join(sources)) assert len(file.export_statements) == len(sources) for i, source in enumerate(sources): @@ -32,137 +32,137 @@ def _export_check(*sources) -> None: # 1. Named exports -def test_named_exports__export_const(export_check) -> None: +def test_named_exports__export_const(export_check): export_check("export const variable = value;") -def test_named_exports__export_let(export_check) -> None: +def test_named_exports__export_let(export_check): export_check("export let variable = value;") -def test_named_exports__export_var(export_check) -> None: +def test_named_exports__export_var(export_check): export_check("export var variable = value;") -def test_named_exports__export_function(export_check) -> None: +def test_named_exports__export_function(export_check): export_check("export function functionName() { /* ... */ }") -def test_named_exports__export_class(export_check) -> None: +def test_named_exports__export_class(export_check): export_check("export class ClassName { /* ... */ }") -def test_named_exports__export_interface(export_check) -> None: +def test_named_exports__export_interface(export_check): export_check("export interface InterfaceName { /* ... */ }") -def test_named_exports__export_type(export_check) -> None: +def test_named_exports__export_type(export_check): export_check("export type TypeName = value;") -def test_named_exports__export_enum(export_check) -> None: +def test_named_exports__export_enum(export_check): export_check("export enum EnumName { /* ... */ }") # 2. Default exports -def test_default_exports__export_default_value(export_check) -> None: +def test_default_exports__export_default_value(export_check): export_check("export default value;") -def test_default_exports__export_default_function(export_check) -> None: +def test_default_exports__export_default_function(export_check): export_check("export default function() { /* ... */ }") -def test_default_exports__export_default_class(export_check) -> None: +def test_default_exports__export_default_class(export_check): export_check("export default class { /* ... */ }") # 3. Exporting declarations after they're defined -def test_defined_declarations__just_export_statement(export_check) -> None: +def test_defined_declarations__just_export_statement(export_check): export_check("export { variable, functionName, ClassName };") # 4. Exporting with aliases -def test_exporting_with_aliases(export_check) -> None: +def test_exporting_with_aliases(export_check): export_check("export { variable as aliasName };") # 5. Re-exporting -def test_reexporting__export_many_names(export_check) -> None: +def test_reexporting__export_many_names(export_check): export_check("export { name1, name2 } from './other-module';") -def test_reexporting__export_many_names_with_aliases(export_check) -> None: +def test_reexporting__export_many_names_with_aliases(export_check): export_check("export { import1 as name1, import2 as name2 } from './other-module';") -def test_reexporting__export_star(export_check) -> None: +def test_reexporting__export_star(export_check): export_check("export * from './other-module';") -def test_reexporting__export_default(export_check) -> None: +def test_reexporting__export_default(export_check): export_check("export { default } from './other-module';") # 6. Combining default and named exports -def test_default_named__export_default_class(export_check) -> None: +def test_default_named__export_default_class(export_check): export_check("export default class { /* ... */ }") -def test_default_named__export_const(export_check) -> None: +def test_default_named__export_const(export_check): export_check("export const namedExport = value;") # 7. Exporting types -def test_types__export_type_block(export_check) -> None: +def test_types__export_type_block(export_check): export_check("export type { SomeType } from './types';") # 8. Exporting namespaces -def test_export_namespace(export_check) -> None: +def test_export_namespace(export_check): export_check("export namespace MyNamespace { export const something = value; }") # 9. Exporting as a namespace -def test_export_star_as_namespace(export_check) -> None: +def test_export_star_as_namespace(export_check): export_check("export * as myNamespace from './module';") # 10. Exporting declarations with modifiers -def test_declaration_with_modifiers__export_abstract_class(export_check) -> None: +def test_declaration_with_modifiers__export_abstract_class(export_check): export_check("export abstract class AbstractClass { /* ... */ }") -def test_declaration_with_modifiers__export_const_enum(export_check) -> None: +def test_declaration_with_modifiers__export_const_enum(export_check): export_check("export const enum ConstEnum { /* ... */ }") # 11. Exporting with generics -def test_generics__export_function(export_check) -> None: +def test_generics__export_function(export_check): export_check("export function genericFunction() { /* ... */ }") -def test_generics__export_class(export_check) -> None: +def test_generics__export_class(export_check): export_check("export class GenericClass { /* ... */ }") diff --git a/tests/unit/codegen/sdk/typescript/function/test_function_async.py b/tests/unit/codegen/sdk/typescript/function/test_function_async.py index 9ac41feaa..8383b911b 100644 --- a/tests/unit/codegen/sdk/typescript/function/test_function_async.py +++ b/tests/unit/codegen/sdk/typescript/function/test_function_async.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_function_is_async_basic(tmpdir) -> None: +def test_function_is_async_basic(tmpdir): # language=typescript content = """ function foo(): void { @@ -66,7 +66,7 @@ class MyClass { ) -def test_function_is_async_extended(tmpdir) -> None: +def test_function_is_async_extended(tmpdir): # language=typescript content = """ /** Docstring */ @@ -146,7 +146,7 @@ class MyClass { ) -def test_function_is_async_other_syntax(tmpdir) -> None: +def test_function_is_async_other_syntax(tmpdir): # language=typescript content = """ // Arrow functions diff --git a/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py b/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py index 2e00b5687..871518f3a 100644 --- a/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py +++ b/tests/unit/codegen/sdk/typescript/function/test_function_calls_from_symbol.py @@ -13,7 +13,7 @@ from codegen.sdk.typescript.statements.assignment_statement import TSAssignmentStatement -def test_function_calls_from_file(tmpdir) -> None: +def test_function_calls_from_file(tmpdir): # language=typescript content = """ import { x, y, z } from './some_file'; @@ -59,7 +59,7 @@ def test_function_calls_from_file(tmpdir) -> None: ] -def test_function_calls_from_class(tmpdir) -> None: +def test_function_calls_from_class(tmpdir): # language=typescript content = """ import { bar } from './some_file'; @@ -100,7 +100,7 @@ class A { @pytest.mark.skip(reason="CG-9422 TS method decorator parsing needs to be fixed first") -def test_function_calls_from_decorated_definitions(tmpdir) -> None: +def test_function_calls_from_decorated_definitions(tmpdir): # language=typescript content = """ import { describe, it } from 'jest'; @@ -139,7 +139,7 @@ class A { @pytest.mark.xfail(reason="Broken by function call changes") -def test_function_calls_from_datatypes(tmpdir) -> None: +def test_function_calls_from_datatypes(tmpdir): # language=typescript content = """ function getConfig(): { max_retries: number; timeout: number } { @@ -178,7 +178,7 @@ def test_function_calls_from_datatypes(tmpdir) -> None: ] -def test_function_calls_from_function_parameters(tmpdir) -> None: +def test_function_calls_from_function_parameters(tmpdir): # language=typescript content = """ // function parameters @@ -200,7 +200,7 @@ def test_function_calls_from_function_parameters(tmpdir) -> None: ] -def test_function_calls_from_while_loop(tmpdir) -> None: +def test_function_calls_from_while_loop(tmpdir): # language=typescript content = """ // while loop conditions @@ -222,7 +222,7 @@ def test_function_calls_from_while_loop(tmpdir) -> None: assert file.function_calls[1].parent.statement_type == StatementType.EXPRESSION_STATEMENT -def test_function_calls_from_if_conditions(tmpdir) -> None: +def test_function_calls_from_if_conditions(tmpdir): # language=typescript content = """ // if conditions @@ -247,7 +247,7 @@ def test_function_calls_from_if_conditions(tmpdir) -> None: ] -def test_function_calls_for_nested_calls(tmpdir) -> None: +def test_function_calls_for_nested_calls(tmpdir): # language=typescript content = """ parent(nested()) @@ -265,7 +265,7 @@ def test_function_calls_for_nested_calls(tmpdir) -> None: ] -def test_function_calls_for_chained_calls(tmpdir) -> None: +def test_function_calls_for_chained_calls(tmpdir): # language=typescript content = """ parent().child().grandchild() @@ -287,7 +287,7 @@ def test_function_calls_for_chained_calls(tmpdir) -> None: assert fcalls[2].parent.parent == fcalls[1] -def test_function_calls_in_function_call(tmpdir) -> None: +def test_function_calls_in_function_call(tmpdir): # language=typescript content = """ describe("top level", () => { diff --git a/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py b/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py index 8ed0e838f..13b2100bf 100644 --- a/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py +++ b/tests/unit/codegen/sdk/typescript/function/test_function_parameter_to_interface.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_convert_simple_props_to_interface(tmpdir) -> None: +def test_convert_simple_props_to_interface(tmpdir): # language=typescript content = """ function Button(props: { @@ -40,7 +40,7 @@ def test_convert_simple_props_to_interface(tmpdir) -> None: ) -def test_convert_props_to_interface_with_complex_types(tmpdir) -> None: +def test_convert_props_to_interface_with_complex_types(tmpdir): # language=typescript content = """ function DataGrid(props: { @@ -75,7 +75,7 @@ def test_convert_props_to_interface_with_complex_types(tmpdir) -> None: ) -def test_convert_props_to_interface_with_generics(tmpdir) -> None: +def test_convert_props_to_interface_with_generics(tmpdir): # language=typescript content = """ function List(props: { @@ -111,7 +111,7 @@ def test_convert_props_to_interface_with_generics(tmpdir) -> None: ) -def test_convert_props_to_interface_with_extends(tmpdir) -> None: +def test_convert_props_to_interface_with_extends(tmpdir): # language=typescript content = """ function CustomButton(props: { diff --git a/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py b/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py index 773accab5..33527dab5 100644 --- a/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py +++ b/tests/unit/codegen/sdk/typescript/import_resolution/test_is_dynamic.py @@ -2,7 +2,7 @@ from codegen.sdk.enums import ProgrammingLanguage -def test_ts_import_is_dynamic_in_function_declaration(tmpdir) -> None: +def test_ts_import_is_dynamic_in_function_declaration(tmpdir): # language=typescript content = """ import { staticImport } from './static'; @@ -21,7 +21,7 @@ def test_ts_import_is_dynamic_in_function_declaration(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in function -def test_ts_import_is_dynamic_in_method_definition(tmpdir) -> None: +def test_ts_import_is_dynamic_in_method_definition(tmpdir): # language=typescript content = """ import { Component } from '@angular/core'; @@ -46,7 +46,7 @@ class MyComponent { assert imports[2].is_dynamic # dynamic import in decorated method -def test_ts_import_is_dynamic_in_arrow_function(tmpdir) -> None: +def test_ts_import_is_dynamic_in_arrow_function(tmpdir): # language=typescript content = """ import { useState } from 'react'; @@ -67,7 +67,7 @@ def test_ts_import_is_dynamic_in_arrow_function(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in async arrow function -def test_ts_import_is_dynamic_in_if_statement(tmpdir) -> None: +def test_ts_import_is_dynamic_in_if_statement(tmpdir): # language=typescript content = """ import { isFeatureEnabled } from './utils'; @@ -91,7 +91,7 @@ def test_ts_import_is_dynamic_in_if_statement(tmpdir) -> None: assert imports[2].is_dynamic # dynamic import in else block -def test_ts_import_is_dynamic_in_try_statement(tmpdir) -> None: +def test_ts_import_is_dynamic_in_try_statement(tmpdir): # language=typescript content = """ import { logger } from './logger'; @@ -112,7 +112,7 @@ def test_ts_import_is_dynamic_in_try_statement(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in try block -def test_ts_import_is_dynamic_in_catch_clause(tmpdir) -> None: +def test_ts_import_is_dynamic_in_catch_clause(tmpdir): # language=typescript content = """ import { logger } from './logger'; @@ -132,7 +132,7 @@ def test_ts_import_is_dynamic_in_catch_clause(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in catch block -def test_ts_import_is_dynamic_in_finally_clause(tmpdir) -> None: +def test_ts_import_is_dynamic_in_finally_clause(tmpdir): # language=typescript content = """ import { logger } from './logger'; @@ -154,7 +154,7 @@ def test_ts_import_is_dynamic_in_finally_clause(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in finally block -def test_ts_import_is_dynamic_in_while_statement(tmpdir) -> None: +def test_ts_import_is_dynamic_in_while_statement(tmpdir): # language=typescript content = """ import { condition } from './utils'; @@ -172,7 +172,7 @@ def test_ts_import_is_dynamic_in_while_statement(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in while loop -def test_ts_import_is_dynamic_in_for_statement(tmpdir) -> None: +def test_ts_import_is_dynamic_in_for_statement(tmpdir): # language=typescript content = """ import { items } from './data'; @@ -190,7 +190,7 @@ def test_ts_import_is_dynamic_in_for_statement(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in for loop -def test_ts_import_is_dynamic_in_do_statement(tmpdir) -> None: +def test_ts_import_is_dynamic_in_do_statement(tmpdir): # language=typescript content = """ import { shouldContinue } from './utils'; @@ -208,7 +208,7 @@ def test_ts_import_is_dynamic_in_do_statement(tmpdir) -> None: assert imports[1].is_dynamic # dynamic import in do-while loop -def test_ts_import_is_dynamic_in_switch_statement(tmpdir) -> None: +def test_ts_import_is_dynamic_in_switch_statement(tmpdir): # language=typescript content = """ import { getFeatureFlag } from './utils'; diff --git a/tests/unit/codegen/sdk/typescript/react/test_interface_props.py b/tests/unit/codegen/sdk/typescript/react/test_interface_props.py index 8011f97f9..8afaa33c3 100644 --- a/tests/unit/codegen/sdk/typescript/react/test_interface_props.py +++ b/tests/unit/codegen/sdk/typescript/react/test_interface_props.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_convert_props_to_interface_with_proptypes_oneof(tmpdir) -> None: +def test_convert_props_to_interface_with_proptypes_oneof(tmpdir): # language=typescript content = """ import { PropTypes } from 'react'; @@ -53,7 +53,7 @@ def test_convert_props_to_interface_with_proptypes_oneof(tmpdir) -> None: ) -def test_convert_class_props_to_interface_with_proptypes_oneof(tmpdir) -> None: +def test_convert_class_props_to_interface_with_proptypes_oneof(tmpdir): # language=typescript content = """ import { PropTypes } from 'react'; @@ -103,7 +103,7 @@ class Component extends React.Component { ) -def test_convert_simple_function_props_to_interface(tmpdir) -> None: +def test_convert_simple_function_props_to_interface(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -140,7 +140,7 @@ def test_convert_simple_function_props_to_interface(tmpdir) -> None: ) -def test_convert_complex_function_props_to_interface(tmpdir) -> None: +def test_convert_complex_function_props_to_interface(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -210,7 +210,7 @@ def test_convert_complex_function_props_to_interface(tmpdir) -> None: ) -def test_convert_simple_class_props_to_interface(tmpdir) -> None: +def test_convert_simple_class_props_to_interface(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -255,7 +255,7 @@ class Component extends React.Component { ) -def test_convert_function_props_with_inferred_parameters_to_interface(tmpdir) -> None: +def test_convert_function_props_with_inferred_parameters_to_interface(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -316,7 +316,7 @@ def test_convert_function_props_with_inferred_parameters_to_interface(tmpdir) -> ) -def test_convert_class_props_with_inferred_parameters_to_interface(tmpdir) -> None: +def test_convert_class_props_with_inferred_parameters_to_interface(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -383,7 +383,7 @@ class Component extends React.Component { ) -def test_convert_props_to_interface_with_any_params(tmpdir) -> None: +def test_convert_props_to_interface_with_any_params(tmpdir): # language=typescript content = """ import { PropTypes } from 'react'; @@ -420,7 +420,7 @@ def test_convert_props_to_interface_with_any_params(tmpdir) -> None: ) -def test_convert_class_props_to_interface_with_any_params(tmpdir) -> None: +def test_convert_class_props_to_interface_with_any_params(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -465,7 +465,7 @@ class Component extends React.Component { ) -def test_convert_complex_class_props_to_interface(tmpdir) -> None: +def test_convert_complex_class_props_to_interface(tmpdir): # language=typescript content = """ import React, { PropTypes } from "react"; @@ -549,7 +549,7 @@ class Component extends React.Component { ) -def test_convert_props_to_interface_with_nested_structures(tmpdir) -> None: +def test_convert_props_to_interface_with_nested_structures(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -636,7 +636,7 @@ def test_convert_props_to_interface_with_nested_structures(tmpdir) -> None: ) -def test_convert_class_props_to_interface_with_nested_structures(tmpdir) -> None: +def test_convert_class_props_to_interface_with_nested_structures(tmpdir): # language=typescript content = """ import React, { PropTypes } from 'react'; @@ -737,7 +737,7 @@ class OtherComponent extends React.Component { ) -def test_convert_props_to_interface_with_proptypes_node_and_element(tmpdir) -> None: +def test_convert_props_to_interface_with_proptypes_node_and_element(tmpdir): # language=typescript content = """ import { PropTypes } from 'react'; diff --git a/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py b/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py index b5284739f..dc4f975a1 100644 --- a/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py +++ b/tests/unit/codegen/sdk/typescript/react/test_ts_declassify.py @@ -7,7 +7,7 @@ from codegen.sdk.typescript.file import TSFile -def test_declassify_class_component(tmpdir) -> None: +def test_declassify_class_component(tmpdir): # language=typescript content = """ import React from "react"; diff --git a/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py b/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py index 102cd8055..8cc9b1ee7 100644 --- a/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py +++ b/tests/unit/codegen/sdk/typescript/statements/if_block_statement/test_if_block_reduce_block.py @@ -10,7 +10,7 @@ from codegen.sdk.typescript.file import TSFile -def test_reduce_condition_to_true_elif(tmpdir) -> None: +def test_reduce_condition_to_true_elif(tmpdir): # language=typescript content = """ function foo(): void { @@ -46,7 +46,7 @@ def test_reduce_condition_to_true_elif(tmpdir) -> None: ) -def test_reduce_condition_to_false_elif(tmpdir) -> None: +def test_reduce_condition_to_false_elif(tmpdir): # language=typescript content = """ function foo(): void { @@ -80,7 +80,7 @@ def test_reduce_condition_to_false_elif(tmpdir) -> None: ) -def test_reduce_condition_to_true_else(tmpdir) -> None: +def test_reduce_condition_to_true_else(tmpdir): # language=typescript content = """ function foo(): void { @@ -109,7 +109,7 @@ def test_reduce_condition_to_true_else(tmpdir) -> None: ) -def test_reduce_condition_to_false_else(tmpdir) -> None: +def test_reduce_condition_to_false_else(tmpdir): # language=typescript content = """ function foo(): void { @@ -138,7 +138,7 @@ def test_reduce_condition_to_false_else(tmpdir) -> None: ) -def test_reduce_condition_multiple_if_blocks(tmpdir) -> None: +def test_reduce_condition_multiple_if_blocks(tmpdir): # language=typescript content = """ function foo(): void { @@ -176,7 +176,7 @@ def test_reduce_condition_multiple_if_blocks(tmpdir) -> None: ) -def test_reduce_condition_nested_if(tmpdir) -> None: +def test_reduce_condition_nested_if(tmpdir): # language=typescript content = """ class MyClass { @@ -228,7 +228,7 @@ class MyClass { ) -def test_reduce_condition_else_if_to_true(tmpdir) -> None: +def test_reduce_condition_else_if_to_true(tmpdir): # language=typescript content = """ function foo(): void { @@ -269,7 +269,7 @@ def test_reduce_condition_else_if_to_true(tmpdir) -> None: ) -def test_reduce_condition_else_if_to_false(tmpdir) -> None: +def test_reduce_condition_else_if_to_false(tmpdir): # language=typescript content = """ function foo(): void { @@ -307,7 +307,7 @@ def test_reduce_condition_else_if_to_false(tmpdir) -> None: ) -def test_reduce_condition_else_statement_raises(tmpdir) -> None: +def test_reduce_condition_else_statement_raises(tmpdir): # language=typescript content = """ function foo(): void { @@ -328,7 +328,7 @@ def test_reduce_condition_else_statement_raises(tmpdir) -> None: else_block.reduce_condition(True) -def test_reduce_condition_to_true_single_if(tmpdir) -> None: +def test_reduce_condition_to_true_single_if(tmpdir): # language=typescript content = """ function foo(): void { @@ -355,7 +355,7 @@ def test_reduce_condition_to_true_single_if(tmpdir) -> None: ) -def test_reduce_condition_to_false_single_if(tmpdir) -> None: +def test_reduce_condition_to_false_single_if(tmpdir): # language=typescript content = """ function foo(): void { diff --git a/tests/unit/codegen/shared/compilation/test_codeblock_validation.py b/tests/unit/codegen/shared/compilation/test_codeblock_validation.py index af0e8593e..0f69ad463 100644 --- a/tests/unit/codegen/shared/compilation/test_codeblock_validation.py +++ b/tests/unit/codegen/shared/compilation/test_codeblock_validation.py @@ -4,7 +4,7 @@ from codegen.shared.exceptions.compilation import DangerousUserCodeException -def test_no_dangerous_operations() -> None: +def test_no_dangerous_operations(): codeblock = """ print("not dangerous") """ @@ -14,7 +14,7 @@ def test_no_dangerous_operations() -> None: pytest.fail("Unexpected DangerousPythonCodeError raised") -def test_dangerous_operations() -> None: +def test_dangerous_operations(): codeblock = """ print(os.environ["ENV"]) """ diff --git a/tests/unit/codegen/shared/compilation/test_function_compilation.py b/tests/unit/codegen/shared/compilation/test_function_compilation.py index 7c786cc5b..da6ccf44a 100644 --- a/tests/unit/codegen/shared/compilation/test_function_compilation.py +++ b/tests/unit/codegen/shared/compilation/test_function_compilation.py @@ -4,7 +4,7 @@ from codegen.shared.exceptions.compilation import InvalidUserCodeException -def test_valid_func_str_should_not_raise() -> None: +def test_valid_func_str_should_not_raise(): func_str = """ from codegen.sdk.core.codebase import Codebase @@ -17,7 +17,7 @@ def execute(codebase: Codebase): pytest.fail("Unexpected InvalidUserCodeException raised") -def test_valid_func_str_with_nested_should_not_raise() -> None: +def test_valid_func_str_with_nested_should_not_raise(): func_str = """ from codegen.sdk.core.codebase import Codebase @@ -33,7 +33,7 @@ def nested(): pytest.fail("Unexpected InvalidUserCodeException raised") -def test_compile_syntax_error_indent_error_raises() -> None: +def test_compile_syntax_error_indent_error_raises(): func_str = """ def execute(codebase: Codebase): a = 1 @@ -47,7 +47,7 @@ def execute(codebase: Codebase): assert "> 3: a = 1" in error_msg -def test_compile_syntax_error_raises() -> None: +def test_compile_syntax_error_raises(): func_str = """ def execute(codebase: Codebase): print "syntax error" @@ -61,7 +61,7 @@ def execute(codebase: Codebase): assert '> 3: print "syntax error"' in error_msg -def test_compile_non_syntax_error_unicode_error_raises() -> None: +def test_compile_non_syntax_error_unicode_error_raises(): func_str = """ def execute(codebase: Codebase): print("hello")\udcff @@ -78,7 +78,7 @@ def execute(codebase: Codebase): assert "'utf-8' codec can't encode character '\\udcff'" in error_msg -def test_exec_error_non_syntax_error_zero_division_raises() -> None: +def test_exec_error_non_syntax_error_zero_division_raises(): """This is to test that we're handling errors (ex: ZeroDivisionError) that are raised during `exec` properly. NOTE: this case wouldn't happen with an actual func_str from create_function_str_from_codeblock b/c the func_str would just take in a codebase. @@ -95,7 +95,7 @@ def execute(codebase: Codebase, exec_error: int = 1/0): assert "> 2: def execute(codebase: Codebase, exec_error: int = 1/0):" in error_msg -def test_exec_error_non_syntax_error_name_error_raises() -> None: +def test_exec_error_non_syntax_error_name_error_raises(): """This is to test that we're handling errors (ex: NameError) that are raised during `exec` properly. NOTE: this case wouldn't happen with an actual func_str from create_function_str_from_codeblock b/c the func_str would not have any patches. @@ -113,7 +113,7 @@ def execute(codebase: Codebase): assert '> 2: @patch("foo", return_value="bar")' in error_msg -def test_func_str_uses_custom_scope_var_does_not_raise() -> None: +def test_func_str_uses_custom_scope_var_does_not_raise(): """This tests if a func_str references a var that is included in custom scope, it will not raise a NameError. This is to test the case when a group of codemods is run and a later one relies on a local defined in a previous one. """ diff --git a/tests/unit/codegen/shared/compilation/test_function_construction.py b/tests/unit/codegen/shared/compilation/test_function_construction.py index a3bfc55ab..1ba1fe6c9 100644 --- a/tests/unit/codegen/shared/compilation/test_function_construction.py +++ b/tests/unit/codegen/shared/compilation/test_function_construction.py @@ -3,7 +3,7 @@ from codegen.shared.compilation.function_construction import create_function_str_from_codeblock -def test_no_execute_func_wraps() -> None: +def test_no_execute_func_wraps(): codeblock = """ print(len(codebase.files)) """ @@ -18,7 +18,7 @@ def execute(codebase: Codebase, pr_options: PROptions | None = None, pr = None, ) -def test_func_name_already_exists() -> None: +def test_func_name_already_exists(): codeblock = """ def execute(codebase: Codebase): print(len(codebase.files)) @@ -27,7 +27,7 @@ def execute(codebase: Codebase): assert codeblock in func -def test_func_name_not_execute() -> None: +def test_func_name_not_execute(): codeblock = """ print(len(codebase.files)) """ @@ -42,7 +42,7 @@ def not_execute(codebase: Codebase, pr_options: PROptions | None = None, pr = No ) -def test_function_str_includes_imports() -> None: +def test_function_str_includes_imports(): codeblock = """ print(len(codebase.files)) """ diff --git a/tests/unit/codegen/shared/compilation/test_string_to_code.py b/tests/unit/codegen/shared/compilation/test_string_to_code.py index cc92d0a66..7d71ab50e 100644 --- a/tests/unit/codegen/shared/compilation/test_string_to_code.py +++ b/tests/unit/codegen/shared/compilation/test_string_to_code.py @@ -8,7 +8,7 @@ from codegen.shared.exceptions.control_flow import StopCodemodException -def test_syntax_error_raises() -> None: +def test_syntax_error_raises(): codeblock = """ print "syntax error" """ @@ -20,7 +20,7 @@ def test_syntax_error_raises() -> None: assert 'print "syntax error"' in error_msg -def test_print_os_environ_raises() -> None: +def test_print_os_environ_raises(): codeblock = """ print(os.environ["ENV"]) """ @@ -28,7 +28,7 @@ def test_print_os_environ_raises() -> None: create_execute_function_from_codeblock(codeblock=codeblock) -def test_print_calls_codebase_log() -> None: +def test_print_calls_codebase_log(): """Test print is monkey patched to call codebase.log""" codeblock = """ print("actually codebase.log") @@ -40,7 +40,7 @@ def test_print_calls_codebase_log() -> None: assert mock_log.call_args_list[0][0][0] == "actually codebase.log" -def test_set_custom_scope_does_not_raise() -> None: +def test_set_custom_scope_does_not_raise(): """Test if the custom scope is set and the codeblock uses a var defined in the scope, it does not raise a NameError.""" codeblock = """ print(local_a) @@ -53,7 +53,7 @@ def test_set_custom_scope_does_not_raise() -> None: @patch("codegen.shared.compilation.string_to_code.logger") -def test_stop_codemod_execution_logs_and_raises(mock_logger) -> None: +def test_stop_codemod_execution_logs_and_raises(mock_logger): codeblock = """ local_a = "this is local_a" raise StopCodemodException("test exception") @@ -65,7 +65,7 @@ def test_stop_codemod_execution_logs_and_raises(mock_logger) -> None: mock_logger.info.call_args_list[1][0][0] == "Stopping codemod due to StopCodemodException: test exception" -def test_references_import_from_generated_imports_does_not_raise() -> None: +def test_references_import_from_generated_imports_does_not_raise(): codeblock = """ print(os.getcwd()) # test external import print(MessageType.GITHUB) # test gs private import @@ -77,7 +77,7 @@ def test_references_import_from_generated_imports_does_not_raise() -> None: assert mock_log.call_count == 3 -def test_references_import_not_in_generated_imports_raises_runtime_error() -> None: +def test_references_import_not_in_generated_imports_raises_runtime_error(): codeblock = """ print(Chainable.__name__) """ @@ -90,7 +90,7 @@ def test_references_import_not_in_generated_imports_raises_runtime_error() -> No assert "> 1: print(Chainable.__name__)" in error_msg -def test_error_during_execution_raises_runtime_error() -> None: +def test_error_during_execution_raises_runtime_error(): codeblock = """ print(var_that_does_not_exist) """ @@ -105,7 +105,7 @@ def test_error_during_execution_raises_runtime_error() -> None: @pytest.mark.xfail(reason="TODO(CG-9581): fix codeblocks with return statements") -def test_return_statement_still_returns_locals() -> None: +def test_return_statement_still_returns_locals(): """Test if there is a return statement in a customer code block, the function should still return the locals""" codeblock = """ local_a = "this is local_a" diff --git a/tests/unit/codemods/test_codemod.py b/tests/unit/codemods/test_codemod.py index 6d00a026d..a9e7b1949 100644 --- a/tests/unit/codemods/test_codemod.py +++ b/tests/unit/codemods/test_codemod.py @@ -2,8 +2,8 @@ from codemods.codemod import Codemod -def test_codemod_execute() -> None: - def sample_execute(codebase: Codebase) -> None: +def test_codemod_execute(): + def sample_execute(codebase: Codebase): for file in codebase.files: file.content = "print('hello')" diff --git a/tests/unit/skills/implementations/ai_skills.py b/tests/unit/skills/implementations/ai_skills.py index 87f236511..16829b5df 100644 --- a/tests/unit/skills/implementations/ai_skills.py +++ b/tests/unit/skills/implementations/ai_skills.py @@ -25,7 +25,7 @@ class RefactorClass(Skill, ABC): @staticmethod @skill_impl(test_cases=[RefactorClassPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): my_class = codebase.get_symbol("MyClass", optional=True) if my_class is None: msg = "MyClass not found in codebase" @@ -49,7 +49,7 @@ class GenerateDocstrings(Skill, ABC): @staticmethod @skill_impl(test_cases=[GenerateDocstringsPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): for cls in codebase.classes: for method in cls.methods: new_docstring = codebase.ai( @@ -73,7 +73,7 @@ class WriteTest(Skill, ABC): @staticmethod @skill_impl(test_cases=[WriteTestPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): my_function = codebase.get_function("my_function", optional=True) if my_function is None: msg = "my_function not found in codebase" @@ -100,7 +100,7 @@ class RenameMethods(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameMethodsPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): for cls in codebase.classes: for method in cls.methods: new_name = codebase.ai(f"Create a better name for the method {method.name}.", target=method) diff --git a/tests/unit/skills/implementations/asyncify_skills.py b/tests/unit/skills/implementations/asyncify_skills.py index 66c3bd65d..d6640adae 100644 --- a/tests/unit/skills/implementations/asyncify_skills.py +++ b/tests/unit/skills/implementations/asyncify_skills.py @@ -133,7 +133,7 @@ class AsyncifyFunctionSkill(Skill): """ @staticmethod - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): pass @staticmethod @@ -158,7 +158,7 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: @staticmethod @skill_impl([SkillTestCase(files=ts_files)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): func_to_convert = codebase.get_function("funcToConvert") convert_queue = deque([func_to_convert]) diff --git a/tests/unit/skills/implementations/code_block_skills.py b/tests/unit/skills/implementations/code_block_skills.py index bcdb07b68..1001bb7bb 100644 --- a/tests/unit/skills/implementations/code_block_skills.py +++ b/tests/unit/skills/implementations/code_block_skills.py @@ -85,7 +85,7 @@ class UnwrapFunctionBody(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_input, output=py_output_unwrap_function)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Unwraps the body of all functions in the file""" # iterate through all functions in the codebase for function in codebase.functions: @@ -94,7 +94,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCaseTSFile(input=ts_input, output=ts_output_unwrap_function)])], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Unwraps the body of all functions in the file""" # iterate through all functions in the codebase for function in codebase.functions: @@ -145,7 +145,7 @@ class UnwrapIfStatement(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_input, output=py_output_unwrap_if_statement)])], language=ProgrammingLanguage.PYTHON) @skill_impl([SkillTestCase(files=[SkillTestCaseTSFile(input=ts_input, output=ts_output_unwrap_if_statement)])], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): for file in codebase.files: for if_block in file.code_block.if_blocks: if_block.consequence_block.unwrap() @@ -174,7 +174,7 @@ class UnwrapWithStatement(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_input, output=py_output_unwrap_with_statement)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Unwraps the body of all with statements in the file""" # for all functions in the codebase for function in codebase.functions: @@ -185,7 +185,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """With Statements are not supported in TypeScript""" ... @@ -377,7 +377,7 @@ class ConvertStatementToArgument(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=py_convert_test_assertion_input, output=py_convert_test_assertion_output)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Transform test assertion statements into an argument to test functions that make a call to a http method.""" methods = ["post", "get", "put", "delete", "patch"] client_name = "client" @@ -415,7 +415,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCaseTSFile(input=ts_convert_test_assertion_input, output=ts_convert_test_assertion_output)])], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Transform test assertion statements into an argument to test functions that make a call to a http method.""" methods = ["post", "get", "put", "delete", "patch"] client_name = "client" diff --git a/tests/unit/skills/implementations/comment_skills.py b/tests/unit/skills/implementations/comment_skills.py index 07e03492e..917662a27 100644 --- a/tests/unit/skills/implementations/comment_skills.py +++ b/tests/unit/skills/implementations/comment_skills.py @@ -52,7 +52,7 @@ class EslintCommentSkill(Skill): @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): ESLINT_RULE = "@typescript-eslint/no-explicit-any" # Iterate over all files in the codebase diff --git a/tests/unit/skills/implementations/decorator_skills.py b/tests/unit/skills/implementations/decorator_skills.py index 7874c2847..549101580 100644 --- a/tests/unit/skills/implementations/decorator_skills.py +++ b/tests/unit/skills/implementations/decorator_skills.py @@ -44,7 +44,7 @@ class AddDecoratorToFunction(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Adds a decorator to each function or method in the codebase if they do not already have it.""" # get the decorator symbol decorator_symbol = codebase.get_symbol("my_decorator") @@ -72,7 +72,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """TODO: Implement this method @Rishi Desai""" ... @@ -134,7 +134,7 @@ class UpdateDocStringOfDecoratedMethods(Skill, ABC): language=ProgrammingLanguage.PYTHON, prompt="Update the docstring of class methods if it has a decarators containing `with_user` in its name by appending 'OPERATES ON USER DATA'.", ) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): for cls in codebase.classes: for method in cls.methods: if method.decorators and any(["with_user" in dec.name for dec in method.decorators]): @@ -146,7 +146,7 @@ def python_skill_func(codebase: CodebaseType) -> None: language=ProgrammingLanguage.TYPESCRIPT, prompt="Update the docstring of class methods if it has a decarators containing `withUser` in its name by appending 'OPERATES ON USER DATA'.", ) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): for cls in codebase.classes: for method in cls.methods: if method.decorators and any(["withUser" in dec.name for dec in method.decorators]): diff --git a/tests/unit/skills/implementations/eval_skills.py b/tests/unit/skills/implementations/eval_skills.py index f20922257..7e4a6b38e 100644 --- a/tests/unit/skills/implementations/eval_skills.py +++ b/tests/unit/skills/implementations/eval_skills.py @@ -25,7 +25,7 @@ class AddCopyrightHeaderSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_1")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): r"""Adds the following header to all files in the codebase: 'Copyright (c) Codegen.\nAll rights reserved.\n\n'""" for file in codebase.files: # Adds header to the file. Note: comments are added @@ -33,7 +33,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_1")], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): r"""Adds the following header to all files in the codebase: '// Copyright (c) Codegen.\n// All rights reserved.\n\n'""" for file in codebase.files: # Adds header to the file. Note: comments are added @@ -46,7 +46,7 @@ class MoveFooFunctionsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_2")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Move all functions starting with 'foo' to foo.py.""" # get the foo.py file if it exists, otherwise create it Note: extension is included in the file name foo_file = codebase.get_file("foo.py") if codebase.has_file("foo.py") else codebase.create_file("foo.py") @@ -60,7 +60,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not Implemented""" ... @@ -71,7 +71,7 @@ class AddDecoratorToFooFunctionsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_3")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Adds the following decorator to all functions starting with 'foo': '@decorator_function'.""" # get the decorator_function symbol decorator_symbol = codebase.get_symbol("decorator_function") @@ -90,7 +90,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not Implemented""" ... @@ -101,7 +101,7 @@ class RenameFooToBarSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_4")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Renames all functions starting with 'foo' to start with 'bar'.""" # for each function in the codebase for function in codebase.functions: @@ -112,7 +112,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not Implemented""" # for each function in the codebase for function in codebase.functions: @@ -128,7 +128,7 @@ class AddReturnTypeHintSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_5")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Adds an int return type hint to all functions starting with 'foo'.""" # for each function in the codebase for function in codebase.functions: @@ -139,7 +139,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not Implemented""" ... @@ -158,7 +158,7 @@ class MoveEnumsToSeparateFileSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_7")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Moves any enums within a file into a file called: `enums.py`. Creates the `enums.py` if it does not exist. If the original file only contains enums this skill renames it to `enums.py` """ @@ -188,7 +188,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not Implemented""" ... @@ -199,13 +199,13 @@ class UpdateOptionalTypeHintsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_8")], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Replaces Optional[type] with type | None in all functions.""" # pattern to match Optional[type] optional_type_pattern = re.compile(r"Optional\[(.*?)]") # update optional parameter type hints - def update_optional_parameter_type_hints(function: PyFunction) -> None: + def update_optional_parameter_type_hints(function: PyFunction): # for each parameter in the function for parameter in function.parameters: # if the parameter is typed @@ -219,7 +219,7 @@ def update_optional_parameter_type_hints(function: PyFunction) -> None: # update the parameter type hint parameter.set_type_annotation(new_type) - def update_optional_return_type_hints(function: PyFunction) -> None: + def update_optional_return_type_hints(function: PyFunction): # if the function has a return type if function.return_type: # get the old return type @@ -249,7 +249,7 @@ def update_optional_return_type_hints(function: PyFunction) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not Implemented""" ... @@ -265,7 +265,7 @@ class DeleteUnusedSymbolsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_3")], language=ProgrammingLanguage.TYPESCRIPT) @skill_impl([SkillTestCase.from_dir(filepath=EVAL_SKILLS_TEST_DIR / "sample_py_6")], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # for each symbol in the codebase for symbol in codebase.symbols: # if the symbol has no usages @@ -290,7 +290,7 @@ class MarkInternalFunctionsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_7")], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Marks all functions that are only used in the `app` directory as an internal function. Marks functions as internal by adding the @internal tag to the bottom of the docstring. """ @@ -325,7 +325,7 @@ def typescript_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Not implemented for Python""" ... @@ -343,7 +343,7 @@ class MoveNonDefaultExportedJSXComponentsSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase.from_dir(EVAL_SKILLS_TEST_DIR / "sample_ts_2")], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Moves all JSX components that are not exported by default into a new file that is in the same directory as the original file.""" # for each file in the codebase for file in codebase.files: @@ -376,6 +376,6 @@ def typescript_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Not implemented for Python""" ... diff --git a/tests/unit/skills/implementations/example_skills.py b/tests/unit/skills/implementations/example_skills.py index b48f7475b..1951a4419 100644 --- a/tests/unit/skills/implementations/example_skills.py +++ b/tests/unit/skills/implementations/example_skills.py @@ -22,7 +22,7 @@ class SetGlobalVarValueSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Set the value of all global variables to 2 if their current assigned literal is 1""" for file in codebase.files: for v in file.global_vars: @@ -31,7 +31,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... @@ -48,7 +48,7 @@ class RenameGlobalVarSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Rename all global variables named 'x' to 'y'.""" for file in codebase.files: for v in file.global_vars: @@ -57,7 +57,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... @@ -136,7 +136,7 @@ class SkipAllTests(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Adds pytest.mark.skip decorator to all test functions with reason="This is a test".""" for file in codebase.files: for function in file.functions: @@ -152,7 +152,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... @@ -173,7 +173,7 @@ class AddTypeHintsSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Adds type hints to function parameters and return values.""" for function in codebase.functions: if not function.return_type: @@ -195,7 +195,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" """Adds type hints to function parameters and return values.""" for function in codebase.functions: @@ -241,7 +241,7 @@ class RenameClassSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Rename the class OldName => NewName""" old_name = "OldName" new_name = "NewName" @@ -252,7 +252,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... @@ -311,7 +311,7 @@ class AddWrapperFunctionSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Add a trivial wrapper function called `new_{function.name}` around each function and class method that just calls the original function.""" for file in codebase.files: for function in file.functions: @@ -327,7 +327,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... @@ -363,7 +363,7 @@ class RemoveUnusedImportsSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Removes unused import statements from the code.""" for file in codebase.files: for imp in file.imports: @@ -372,7 +372,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... @@ -406,7 +406,7 @@ class AddDocstringsSkill(Skill, ABC): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Adds docstrings to all functions and methods.""" for file in codebase.files: for function in file.functions: @@ -416,6 +416,6 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Not implemented for TypeScript""" ... diff --git a/tests/unit/skills/implementations/export_skills.py b/tests/unit/skills/implementations/export_skills.py index 92f4d1625..a30fea49c 100644 --- a/tests/unit/skills/implementations/export_skills.py +++ b/tests/unit/skills/implementations/export_skills.py @@ -63,7 +63,7 @@ class ExportSkills(Skill): @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): """Convert default exports to named exports in TypeScript""" for file in codebase.files: for export in file.exports: diff --git a/tests/unit/skills/implementations/expressions/dict.py b/tests/unit/skills/implementations/expressions/dict.py index 59e88f5ba..f8e38bbbb 100644 --- a/tests/unit/skills/implementations/expressions/dict.py +++ b/tests/unit/skills/implementations/expressions/dict.py @@ -18,7 +18,7 @@ class DictToSchema(Skill): @staticmethod @skill_impl(test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType) -> None: + def python_skill_func(codebase: PyCodebaseType): """Converts a dictionary into a Schema object. Converts the key value pairs into arguments for the constructor""" # iterate over all global vars for v in codebase.global_vars: diff --git a/tests/unit/skills/implementations/expressions/list.py b/tests/unit/skills/implementations/expressions/list.py index adfa66965..8852e6a92 100644 --- a/tests/unit/skills/implementations/expressions/list.py +++ b/tests/unit/skills/implementations/expressions/list.py @@ -27,7 +27,7 @@ class AppendToGlobalList(Skill, ABC): @staticmethod @skill_impl(test_cases_append_py, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases_append_ts, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): """Append 2 to the global list variable 'a' in Python.""" a = codebase.get_symbol("a") a.value.append("2") @@ -58,7 +58,7 @@ class RemoveFromGlobalList(Skill, ABC): @staticmethod @skill_impl(test_cases_remove_py, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases_remove_ts, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): """Remove 2 from the global list variable 'a'""" a = codebase.get_symbol("a", optional=True) assert a, "Symbol 'a' not found" @@ -87,7 +87,7 @@ class ClearGlobalList(Skill, ABC): @staticmethod @skill_impl(test_cases_clear_py, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases_clear_ts, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): """Clear the global list variable 'a'""" a = codebase.get_symbol("a") a.value.clear() diff --git a/tests/unit/skills/implementations/expressions/type.py b/tests/unit/skills/implementations/expressions/type.py index 3eb1cca75..fb9eecd67 100644 --- a/tests/unit/skills/implementations/expressions/type.py +++ b/tests/unit/skills/implementations/expressions/type.py @@ -30,7 +30,7 @@ class AppendTypeToUnionTypeSkill(Skill): @staticmethod @skill_impl(test_cases_append_py, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """If the type of 'a' is a UnionType, append "str" to it if it doesn't already exist""" a: PyAssignment = codebase.get_symbol("a") if isinstance(a.type, UnionType): @@ -39,7 +39,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases_append_ts, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """If the type of 'a' is a UnionType, append "str" to it if it doesn't already exist""" a: TSAssignment = codebase.get_symbol("a") if isinstance(a.type, UnionType): @@ -73,7 +73,7 @@ class ConvertToBuiltInTypeSkill(Skill): @staticmethod @skill_impl([SkillTestCase(files=[SkillTestCasePyFile(input=built_in_type_input, output=built_in_type_output)])], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): """Replaces type annotations using typing module with builtin types.""" import_replacements = {"List": "list", "Dict": "dict", "Set": "set", "Tuple": "tuple"} @@ -92,6 +92,6 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl([], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """The typing package is only available in Python""" ... diff --git a/tests/unit/skills/implementations/feature_flag_deletion_skill.py b/tests/unit/skills/implementations/feature_flag_deletion_skill.py index 303d13693..17744025f 100644 --- a/tests/unit/skills/implementations/feature_flag_deletion_skill.py +++ b/tests/unit/skills/implementations/feature_flag_deletion_skill.py @@ -101,7 +101,7 @@ class DeleteRolledOutFeatureFlagSkill(Skill, ABC): @staticmethod @skill_impl([SkillTestCase(files=py_files)], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType) -> None: + def python_skill_func(codebase: PyCodebaseType): """Implements the feature flag deletion for Python codebases.""" feature_flag = codebase.get_symbol("ROLLED_OUT_FLAG_TO_DELETE") feature_flag_name = feature_flag.name @@ -123,7 +123,7 @@ def python_skill_func(codebase: PyCodebaseType) -> None: @staticmethod @skill_impl([SkillTestCase(files=ts_files)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): """Implements the feature flag deletion for TypeScript codebases.""" feature_flag = codebase.get_symbol("ROLLED_OUT_FLAG_TO_DELETE") feature_flag_name = feature_flag.name diff --git a/tests/unit/skills/implementations/function_skills.py b/tests/unit/skills/implementations/function_skills.py index 22403bde0..0168af72a 100644 --- a/tests/unit/skills/implementations/function_skills.py +++ b/tests/unit/skills/implementations/function_skills.py @@ -55,14 +55,14 @@ class AppendParameterSkill(Skill, ABC): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType) -> None: + def python_skill_func(codebase: PyCodebaseType): """Append a parameter to the function signature in Python""" foo = codebase.get_symbol("foo") foo.parameters.append("b: int") @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): """Append a parameter to the function signature in TypeScript""" foo = codebase.get_symbol("foo") foo.parameters.append("b: number") diff --git a/tests/unit/skills/implementations/global_var_skills.py b/tests/unit/skills/implementations/global_var_skills.py index b89fa154e..bf38f9873 100644 --- a/tests/unit/skills/implementations/global_var_skills.py +++ b/tests/unit/skills/implementations/global_var_skills.py @@ -92,7 +92,7 @@ class DeleteUnusedLoggerSkill(Skill, ABC): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType) -> None: + def python_skill_func(codebase: PyCodebaseType): """Remove all global variables that are defined as `logger = get_logger(__name__)` if they are unused""" for file in codebase.files: for var in file.global_vars: @@ -101,7 +101,7 @@ def python_skill_func(codebase: PyCodebaseType) -> None: @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): """Remove all global variables that are defined as `logger = getLogger()` if they are unused""" for file in codebase.files: for var in file.global_vars: diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py b/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py index 8af8bc793..4d4a4c11e 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_app_imports.py @@ -29,7 +29,7 @@ class FileAppImportGraph(Skill, ABC): @staticmethod @skill_impl(test_cases=[FileAppImportGraphTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): import networkx as nx # Create a directed graph diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py b/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py index 059ad37c3..21bbd1a6f 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_call_graph.py @@ -61,7 +61,7 @@ class CallGraphFromNode(Skill, ABC): @staticmethod @skill_impl(test_cases=[CallGraphFromNodeTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Create a directed graph G = nx.DiGraph() @@ -71,7 +71,7 @@ def skill_func(codebase: CodebaseType) -> None: # ===== [ Maximum Recursive Depth ] ===== MAX_DEPTH = 5 - def create_downstream_call_trace(parent: FunctionCall | Function | None = None, depth: int = 0) -> None: + def create_downstream_call_trace(parent: FunctionCall | Function | None = None, depth: int = 0): """Creates call graph for parent This function recurses through the call graph of a function and creates a visualization @@ -194,7 +194,7 @@ class CallGraphFilter(Skill, ABC): @staticmethod @skill_impl(test_cases=[CallGraphFilterTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Create a directed graph G = nx.DiGraph() @@ -212,7 +212,7 @@ def skill_func(codebase: CodebaseType) -> None: cls = codebase.get_class("MyClass") # Define a recursive function to traverse function calls - def create_filtered_downstream_call_trace(parent: FunctionCall | Function, current_depth, max_depth) -> None: + def create_filtered_downstream_call_trace(parent: FunctionCall | Function, current_depth, max_depth): if current_depth > max_depth: return @@ -289,7 +289,7 @@ class CallPathsBetweenNodes(Skill, ABC): @staticmethod @skill_impl(test_cases=[CallPathsBetweenNodesTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Create a directed graph G = nx.DiGraph() @@ -297,7 +297,7 @@ def skill_func(codebase: CodebaseType) -> None: MAX_DEPTH = 5 # Define a recursive function to traverse usages - def create_downstream_call_trace(parent: FunctionCall | Function, end: Callable, current_depth, max_depth) -> None: + def create_downstream_call_trace(parent: FunctionCall | Function, end: Callable, current_depth, max_depth): if current_depth > max_depth: return diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py b/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py index 5a6ed69b4..27b8ed1c3 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_dead_code.py @@ -111,7 +111,7 @@ class DeadCode(Skill, ABC): @staticmethod @skill_impl(test_cases=[PyDeadCodeTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Create a directed graph to visualize dead and second-order dead code G = nx.DiGraph() diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py b/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py index d87674fb0..b5fec176b 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_dir_tree.py @@ -85,7 +85,7 @@ class RepoDirTree(Skill, ABC): @staticmethod @skill_impl(test_cases=[PyRepoDirTreeTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Create a directed graph G = nx.DiGraph() diff --git a/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py b/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py index e57fc8f08..608487257 100644 --- a/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py +++ b/tests/unit/skills/implementations/graph_viz/graph_viz_foreign_key.py @@ -97,7 +97,7 @@ class ForeignKeyGraph(Skill, ABC): @staticmethod @skill_impl(test_cases=[PyForeignKeyGraphTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Create a mapping dictionary to hold relationships foreign_key_mapping = {} diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py b/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py index b349a45a4..ce61479ec 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/import-loops.py @@ -87,7 +87,7 @@ class ImportCycleDetectionAndVisualization(Skill, ABC): @staticmethod @skill_impl(test_cases=[ImportCycleDetectionAndVisualizationTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): G: DiGraph = networkx.DiGraph() # iterate over all imports diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py b/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py index 6a250516c..e8f6eb3b4 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/large-files.py @@ -71,7 +71,7 @@ class CountLargeFiles(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountLargeFilesPyTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CountLargeFilesTSTest], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): file_to_lines = {} for file in codebase.files: file_to_lines[file.filepath] = file.end_point[0] diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py b/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py index f7d909229..a16dbe70c 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py @@ -69,7 +69,7 @@ class AutoDocstringGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[AutoDocstringGeneratorTest], skip_test=True, language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): functions_without_docstring = 0 # Iterate over all functions in the codebase for function in codebase.functions: diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py b/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py index ac3f92254..a918c0ac7 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/unnamed-kwargs.py @@ -83,7 +83,7 @@ class CountUnnamedKeywordArguments(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUnnamedKeywordArgumentsTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): unnamed_kwargs_count = 0 # Iterate through all files in the codebase diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py index 95d954e82..b728735bc 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-attributes.py @@ -120,7 +120,7 @@ class CountUntypedAttributesInCodebase(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUntypedAttributesInCodebasePyTest], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CountUntypedAttributesInCodebaseTSTest], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): untyped_attributes_count = 0 typed_attributes_count = 0 diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py index 8b20fd185..b179f7599 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-parameters.py @@ -76,7 +76,7 @@ class CountUntypedParameters(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUntypedParametersTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): untitled_parameters_count = 0 # Iterate through all files in the codebase diff --git a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py index 11187956c..82b492792 100644 --- a/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py +++ b/tests/unit/skills/implementations/guides/code-quality-metrics/untyped-return-types.py @@ -50,7 +50,7 @@ class CountUntypedReturnStatements(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountUntypedReturnStatementsTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): untitled_return_count = 0 # Iterate through all files in the codebase diff --git a/tests/unit/skills/implementations/guides/codebase-ai.py b/tests/unit/skills/implementations/guides/codebase-ai.py index 251070d33..4140257bc 100644 --- a/tests/unit/skills/implementations/guides/codebase-ai.py +++ b/tests/unit/skills/implementations/guides/codebase-ai.py @@ -44,7 +44,7 @@ class MethodSummaryGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[MethodSummaryGeneratorPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # get the method and its parent class method: Function = codebase.get_class("MyClass").get_method("target_method") parent_class = method.parent @@ -150,7 +150,7 @@ class FunctionDecomposition(Skill, ABC): @staticmethod @skill_impl(test_cases=[FunctionDecompositionPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Get the large function large_function = codebase.get_function("large_function") @@ -194,7 +194,7 @@ class DocstringGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[DocstringGeneratorPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Loop through all functions in the codebase for function in codebase.functions: # Generate a new docstring for the function @@ -237,7 +237,7 @@ class DocstringFormatter(Skill, ABC): @staticmethod @skill_impl(test_cases=[DocstringFormatterPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Loop through all functions in the codebase for function in codebase.functions: # Convert the docstring to the new format diff --git a/tests/unit/skills/implementations/guides/complex-renaming.py b/tests/unit/skills/implementations/guides/complex-renaming.py index 4c2970119..b3694b2aa 100644 --- a/tests/unit/skills/implementations/guides/complex-renaming.py +++ b/tests/unit/skills/implementations/guides/complex-renaming.py @@ -66,7 +66,7 @@ class RenameFunctionAndUpdateReferences(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Find the symbol to rename old_function = codebase.get_file("path/to/file.py").get_function("old_function_name") @@ -75,7 +75,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Find the symbol to rename old_function = codebase.get_file("path/to/file.ts").get_function("old_function_name") @@ -99,7 +99,7 @@ class AutoRenameFunction(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): function = codebase.get_file("path/to/file.py").get_function("old_function_name") function.rename("new_function_name") @@ -110,7 +110,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[RenameFunctionAndUpdateReferencesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): function = codebase.get_file("path/to/file.ts").get_function("old_function_name") function.rename("new_function_name") @@ -189,7 +189,7 @@ class AutomaticClassRenamingWithReferenceUpdate(Skill, ABC): @staticmethod @skill_impl(test_cases=[AutoRenameClassPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[AutoRenameClassTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): old_class = codebase.get_class("OldClassName") old_class.rename("NewClassName") @@ -277,7 +277,7 @@ class RemoveDeprecatedPrefixfromFunctions(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveDeprecatedPrefixfromFunctionsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveDeprecatedPrefixfromFunctionsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate over all codebase functions for function in codebase.functions: # Filter for functions starting with deprecated_ @@ -398,7 +398,7 @@ class RenameMethodInBaseAndSubclasses(Skill, ABC): @staticmethod @skill_impl(test_cases=[RenameMethodPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RenameMethodTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): base_class = codebase.get_class("BaseClass") old_method = base_class.get_method("old_method") diff --git a/tests/unit/skills/implementations/guides/creating-documentation.py b/tests/unit/skills/implementations/guides/creating-documentation.py index 08a458f45..c7fa4cf3e 100644 --- a/tests/unit/skills/implementations/guides/creating-documentation.py +++ b/tests/unit/skills/implementations/guides/creating-documentation.py @@ -57,7 +57,7 @@ class UpdateFunctionDocstring(Skill, ABC): @staticmethod @skill_impl(test_cases=[UpdateFunctionDocstringPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Get a specific function function = codebase.get_file("path/to/file.py").get_function("my_function") # Update its docstring @@ -65,7 +65,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[UpdateFunctionDocstringTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Get a specific function function = codebase.get_file("path/to/file.ts").get_function("myFunction") # Update its docstring @@ -157,7 +157,7 @@ class CalculateDocumentationCoverage(Skill, ABC): @staticmethod @skill_impl(test_cases=[CalculateDocumentationCoveragePyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CalculateDocumentationCoverageTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Initialize counters for total and documented functions/classes count_total = 0 count_documented = 0 @@ -230,7 +230,7 @@ class DocstringEnhancer(Skill, ABC): @staticmethod @skill_impl(test_cases=[DocstringEnhancerPyTestCase], skip_test=True, language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[DocstringEnhancerTSTestCase], skip_test=True, language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): for function in codebase.functions: current_docstring = function.docstring if current_docstring: @@ -363,7 +363,7 @@ class StaticDocstringGenerator(Skill, ABC): @staticmethod @skill_impl(test_cases=[StaticDocstringGeneratorPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[StaticDocstringGeneratorTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate through all functions in the codebase for function in codebase.functions: # Check if the function has a docstring diff --git a/tests/unit/skills/implementations/guides/deleting-dead-code.py b/tests/unit/skills/implementations/guides/deleting-dead-code.py index 67a1bc47a..c6f7a99c4 100644 --- a/tests/unit/skills/implementations/guides/deleting-dead-code.py +++ b/tests/unit/skills/implementations/guides/deleting-dead-code.py @@ -122,7 +122,7 @@ class RemoveUnusedSymbols(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedSymbolsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedSymbolsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate through all symbols in the codebase for symbol in codebase.symbols: # Check if the symbols has no usages @@ -195,7 +195,7 @@ class RemoveUnusedFunctions(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedFunctionsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedFunctionsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate through all functions in the codebase for function in codebase.functions: # Check if the function has no usages and no call sites @@ -262,7 +262,7 @@ class RemoveUnusedImports(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedImportsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedImportsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate through all imports in the codebase for import_stmt in codebase.imports: # Check if the import statement has no usages @@ -335,7 +335,7 @@ class RemoveUnusedLocalVariableAssignments(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedLocalVariableAssignmentsPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedLocalVariableAssignmentsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate through all functions in the codebase for func in codebase.functions: # Iterate through local variable assignments in the function @@ -407,7 +407,7 @@ class RemoveUnusedParametersAndArguments(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedParametersAndArgumentsPyTestCase], language=ProgrammingLanguage.PYTHON, ignore=True) @skill_impl(test_cases=[RemoveUnusedParametersAndArgumentsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # iterate through all functions in the codebase for function in codebase.functions: for param in function.parameters: @@ -492,7 +492,7 @@ class RemoveUnusedClasses(Skill, ABC): @staticmethod @skill_impl(test_cases=[RemoveUnusedClassesPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[RemoveUnusedClassesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Iterate through all classes in the codebase for cls in codebase.classes: # Check if the class has no usages @@ -582,7 +582,7 @@ class CleanUpCodebase(Skill, ABC): @staticmethod @skill_impl(test_cases=[CleanUpCodebasePyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CleanUpCodebaseTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # iterate through all files in the codebase for file in codebase.files: # Check if the file is empty diff --git a/tests/unit/skills/implementations/guides/increase-type-coverage.py b/tests/unit/skills/implementations/guides/increase-type-coverage.py index 04e1c8f22..52bf3a854 100644 --- a/tests/unit/skills/implementations/guides/increase-type-coverage.py +++ b/tests/unit/skills/implementations/guides/increase-type-coverage.py @@ -76,7 +76,7 @@ class CountTypedParametersSkill(Skill, ABC): @staticmethod @skill_impl(test_cases=[CountTypedParametersPyTestCase], language=ProgrammingLanguage.PYTHON) @skill_impl(test_cases=[CountTypedParametersTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Initialize counters for total parameters and typed parameters total_parameters = 0 typed_parameters = 0 @@ -200,7 +200,7 @@ class SetReturnTypeToNoneForFunctionsWithoutReturns(Skill, ABC): @staticmethod @skill_impl(test_cases=[SetReturnTypeToNoneForFunctionsWithoutReturnsPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Iterate through all files in the codebase for file in codebase.files: # Check if 'app' is in the file's filepath @@ -214,7 +214,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[SetReturnTypeToNoneForFunctionsWithoutReturnsTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Iterate through all files in the codebase for file in codebase.files: # Check if 'app' is in the file's filepath @@ -310,7 +310,7 @@ class ModifyReturnTypeSkill(Skill, ABC): @staticmethod @skill_impl(test_cases=[ModifyReturnTypeSkillPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Find the symbol to modify target_file = codebase.get_file("path/to/file.py") function = target_file.get_function("function_name") @@ -325,7 +325,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[ModifyReturnTypeSkillTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Find the symbol to modify target_file = codebase.get_file("path/to/file.ts") function = target_file.get_function("functionName") @@ -378,7 +378,7 @@ class ModifyReturnTypeWithNewParameter(Skill, ABC): @staticmethod @skill_impl(test_cases=[ModifyReturnTypeWithNewParameterTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Find the symbol to modify function = codebase.get_file("path/to/file.py").get_function("function_name") # def function_name() -> tuple[a, b]: ... @@ -419,7 +419,7 @@ class InspectFunctionReturnType(Skill, ABC): @staticmethod @skill_impl(test_cases=[InspectFunctionReturnTypePyTest], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Find the symbol to inspect function = codebase.get_file("path/to/file.py").get_function("function_name") # def function_name() -> tuple[a, b]: ... @@ -533,7 +533,7 @@ class InspectResolveFunctionReturnType(Skill, ABC): @staticmethod @skill_impl(test_cases=[InspectResolveFunctionReturnTypePySanityTest], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Find the symbol to inspect function = codebase.get_file("path/to/file.py").get_function("function_name") # from xyz import MyContainer, a, b @@ -544,7 +544,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[InspectResolveFunctionReturnTypeTSSanityTest], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Find the symbol to inspect function = codebase.get_file("path/to/file.ts").get_function("functionName") # import { MyContainer, a, b } './types' @@ -595,7 +595,7 @@ class ResolveAndRenameGlobalVariableType(Skill, ABC): @staticmethod @skill_impl(test_cases=[ResolveAndRenameGlobalVariableTypeTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): a = codebase.get_file("path/to/file.py").get_global_var("a") # a: MyType = ... print(a.type) # Resolves to MyType diff --git a/tests/unit/skills/implementations/guides/manipulating-collections.py b/tests/unit/skills/implementations/guides/manipulating-collections.py index 0d68f8cce..d95c24bd7 100644 --- a/tests/unit/skills/implementations/guides/manipulating-collections.py +++ b/tests/unit/skills/implementations/guides/manipulating-collections.py @@ -54,7 +54,7 @@ class AddParameterToFunction(Skill, ABC): @staticmethod @skill_impl(test_cases=[AddParameterToFunctionPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Find the symbol to modify function = codebase.get_file("path/to/file.py").get_function("function_name") @@ -63,7 +63,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[AddParameterToFunctionTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Find the symbol to modify function = codebase.get_file("path/to/file.ts").get_function("functionName") @@ -116,7 +116,7 @@ class ModifyDictionaryValue(Skill, ABC): @staticmethod @skill_impl(test_cases=[ModifyDictionaryValuePyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # var = {"example_key": "example_value"} # Find the symbol to modify var = codebase.get_file("path/to/file.py").get_global_var("foo") @@ -134,7 +134,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[ModifyDictionaryValueTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # var = {"example_key": "example_value"} # Find the symbol to modify var = codebase.get_file("path/to/file.ts").get_global_var("foo") @@ -182,7 +182,7 @@ class ConvertVariableToSchema(Skill, ABC): @staticmethod @skill_impl(test_cases=[ConvertVariableToSchemaPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Find the symbol to modify var = codebase.get_file("path/to/file.py").get_global_var("var_name") @@ -232,7 +232,7 @@ class AppendToGlobalVariableList(Skill, ABC): @staticmethod @skill_impl(test_cases=[AppendToGlobalVariableListPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): # Find the symbol to modify var = codebase.get_file("path/to/file.py").get_global_var("foo") @@ -246,7 +246,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[AppendToGlobalVariableListTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): # Find the symbol to modify var = codebase.get_file("path/to/file.ts").get_global_var("foo") @@ -292,7 +292,7 @@ class CheckFunctionDecoratorPresence(Skill, ABC): @staticmethod @skill_impl(test_cases=[CheckFunctionDecoratorPresencePyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Find the symbol to modify function = codebase.get_file("path/to/file.py").get_function("function_name") diff --git a/tests/unit/skills/implementations/guides/organize-your-codebase.py b/tests/unit/skills/implementations/guides/organize-your-codebase.py index d9e9eb79e..b78330b51 100644 --- a/tests/unit/skills/implementations/guides/organize-your-codebase.py +++ b/tests/unit/skills/implementations/guides/organize-your-codebase.py @@ -67,7 +67,7 @@ class SplitFunctionsIntoSeparateFiles(Skill, ABC): @staticmethod @skill_impl(test_cases=[SplitFunctionsIntoSeparateFilesPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Retrieve the Python file from the codebase file = codebase.get_file("path/to/file.py") # Iterate through the functions in the file @@ -147,7 +147,7 @@ class MoveSymbolDemonstration(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolDemonstrationPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): source_file = codebase.get_file("path/to/source_file.py") # =====[ Code Snippet ]===== # Get the symbol @@ -159,7 +159,7 @@ def python_skill_func(codebase: CodebaseType) -> None: @staticmethod @skill_impl(test_cases=[MoveSymbolDemonstrationTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): source_file = codebase.get_file("path/to/source_file.ts") # =====[ Code Snippet ]===== # Get the symbol @@ -247,7 +247,7 @@ class MoveSymbolWithUpdatedImports(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolWithUpdatedImportsPyTestCase], language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: CodebaseType) -> None: + def python_skill_func(codebase: CodebaseType): symbol_to_move = codebase.get_symbol("symbol_to_move") dst_file = codebase.create_file("new_file.py") symbol_to_move.move_to_file(dst_file, strategy="update_all_imports") @@ -337,7 +337,7 @@ class MoveSymbolWithAddBackEdgeStrategy(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolWithAddBackEdgeStrategyPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): symbol_to_move = codebase.get_symbol("symbol_to_move") dst_file = codebase.create_file("new_file.py") symbol_to_move.move_to_file(dst_file, strategy="add_back_edge") @@ -447,14 +447,14 @@ class MoveSymbolToFileWithDependencies(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolToFileWithDependenciesPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): my_symbol = codebase.get_symbol("my_symbol") dst_file = codebase.create_file("new_file.py") my_symbol.move_to_file(dst_file, include_dependencies=True) @staticmethod @skill_impl(test_cases=[MoveSymbolToFileWithDependenciesTSTestCase], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): my_symbol = codebase.get_symbol("mySymbol") dst_file = codebase.create_file("new_file.ts") my_symbol.move_to_file(dst_file, include_dependencies=True) @@ -526,7 +526,7 @@ class MoveSymbolsWithDependencies(Skill, ABC): @staticmethod @skill_impl(test_cases=[MoveSymbolsWithDependenciesPyTestCase], language=ProgrammingLanguage.PYTHON) - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): # Retrieve the source and destination files source_file = codebase.get_file("path/to/source_file.py") dest_file = codebase.get_file("path/to/destination_file.py") diff --git a/tests/unit/skills/implementations/if_statement_skills.py b/tests/unit/skills/implementations/if_statement_skills.py index 33317ae28..aeb3b1991 100644 --- a/tests/unit/skills/implementations/if_statement_skills.py +++ b/tests/unit/skills/implementations/if_statement_skills.py @@ -93,7 +93,7 @@ class ReduceIfStatementConditionSkill(Skill, ABC): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType) -> None: + def python_skill_func(codebase: PyCodebaseType): """Simplifies the if/else control flow by reducing conditions that are `condition_to_set` to True""" for file in codebase.files: for function in file.functions: @@ -106,7 +106,7 @@ def python_skill_func(codebase: PyCodebaseType) -> None: @staticmethod @skill_impl(ts_test_cases, language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): """Simplifies the if/else control flow by reducing conditions that are `conditionToSet` to True""" for file in codebase.files: for function in file.functions: diff --git a/tests/unit/skills/implementations/move_symbols_skills.py b/tests/unit/skills/implementations/move_symbols_skills.py index c6c182d1a..a68b48eec 100644 --- a/tests/unit/skills/implementations/move_symbols_skills.py +++ b/tests/unit/skills/implementations/move_symbols_skills.py @@ -61,7 +61,7 @@ class MoveDataclassesSkills(Skill): @staticmethod @skill_impl(py_test_cases, language=ProgrammingLanguage.PYTHON) - def python_skill_func(codebase: PyCodebaseType) -> None: + def python_skill_func(codebase: PyCodebaseType): """Moves the dataclasses and adds a back edge to the moved symbol in the original file""" # Iterate over all files in the codebase for file in codebase.files: @@ -85,6 +85,6 @@ def python_skill_func(codebase: PyCodebaseType) -> None: @staticmethod @skill_impl([], language=ProgrammingLanguage.TYPESCRIPT, ignore=True) - def typescript_skill_func(codebase: CodebaseType) -> None: + def typescript_skill_func(codebase: CodebaseType): """Dataclasses is only available in Python""" ... diff --git a/tests/unit/skills/implementations/type_inheritance_skills.py b/tests/unit/skills/implementations/type_inheritance_skills.py index 90057b306..e6c3f54df 100644 --- a/tests/unit/skills/implementations/type_inheritance_skills.py +++ b/tests/unit/skills/implementations/type_inheritance_skills.py @@ -224,12 +224,12 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: pass @staticmethod - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): pass @staticmethod @skill_impl([SkillTestCase(files=ts_files_readonly)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): """Given a type alias 'MyMapper', find all inherited or extended implementations of the type object. Loops through all codebase symbols and handles each symbol type accordingly. """ @@ -270,12 +270,12 @@ def python_skill_func(codebase: PyCodebaseType) -> callable: pass @staticmethod - def skill_func(codebase: CodebaseType) -> None: + def skill_func(codebase: CodebaseType): pass @staticmethod @skill_impl([SkillTestCase(files=ts_files_write)], language=ProgrammingLanguage.TYPESCRIPT) - def typescript_skill_func(codebase: TSCodebaseType) -> None: + def typescript_skill_func(codebase: TSCodebaseType): FUNC_NAME_TO_CONVERT = "convert" mapper_symbol: TypeAlias = codebase.get_symbol("MyMapper") @@ -331,4 +331,7 @@ def typescript_skill_func(codebase: TSCodebaseType) -> None: processed.add(f) if not f.is_async: f.asyncify() - funcs_to_asyncify.extend(call_site.parent for call_site in f.call_sites if call_site.parent and isinstance(call_site.parent, Function)) + + for call_site in f.call_sites: + if call_site.parent and isinstance(call_site.parent, Function): + funcs_to_asyncify.append(call_site.parent) diff --git a/tests/unit/skills/test_skills.py b/tests/unit/skills/test_skills.py index f0c04e08a..11d83baca 100644 --- a/tests/unit/skills/test_skills.py +++ b/tests/unit/skills/test_skills.py @@ -13,7 +13,7 @@ # @pytest.pytestmark.skip(reason="AI skill testing") @pytest.mark.parametrize("skill, test_case", [(skill, case) for skill, case, _ in cases], ids=[skill.name + f"-{skill.language.name}-case-{case.name or idx}" for skill, case, idx in cases]) -def test_all_example_skills(tmpdir, skill: SkillImplementation, test_case: SkillTestCase, snapshot) -> None: +def test_all_example_skills(tmpdir, skill: SkillImplementation, test_case: SkillTestCase, snapshot): with get_codebase_session(tmpdir=tmpdir, programming_language=skill.language, files=test_case.to_input_dict(), repo_config=BaseRepoConfig(), verify_output=False, verify_input=False) as codebase: skill._skill_func(codebase) codebase.commit() From 401bdbbf018c03f84c5f2e44886427faf9a8f2af Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 11:16:20 -0800 Subject: [PATCH 04/12] Add more runners --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 25861837c..fa4852599 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -209,7 +209,7 @@ commands: # See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs jobs: unit-tests: - parallelism: 3 + parallelism: 4 executor: default_image resource_class: "large" steps: From 6401089dc4651d4af36e89987147d278b9a83a67 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 12:24:51 -0800 Subject: [PATCH 05/12] increase parallel runners --- .circleci/config.yml | 2 +- scripts/profiling/profile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fa4852599..501dc67c4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -209,7 +209,7 @@ commands: # See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs jobs: unit-tests: - parallelism: 4 + parallelism: 8 executor: default_image resource_class: "large" steps: diff --git a/scripts/profiling/profile.py b/scripts/profiling/profile.py index 4b0264a3e..a32e0282a 100644 --- a/scripts/profiling/profile.py +++ b/scripts/profiling/profile.py @@ -12,7 +12,7 @@ def profile(repo: str, memory: bool = False): output = f"{base}/raw.austin" compressed = f"{base}/compressed.austin" image = f"{base}/parse.svg" - test = Popen(["pytest", "tests/codemod/test_parse.py", "--extra-repos=true", "--durations=100", "-k", repo]) + test = Popen(["pytest", "tests/integration/codemod/test_parse.py", "--extra-repos=true", "--durations=100", "-k", repo]) try: command = ["sudo", "austin", "-p", str(test.pid), "-o", output] if memory: From 7fb48ae77fc743c1b694189b3a49191d47823d85 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 12:45:41 -0800 Subject: [PATCH 06/12] Try commenting out conftest.py --- tests/conftest.py | 118 ++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 61 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 65680b60f..8637e99fe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,4 @@ -import logging import os -from pathlib import Path - -import pytest from tests.shared.codemod.models import Size @@ -67,60 +63,60 @@ def pytest_addoption(parser) -> None: parser.addoption("--cli-api-key", action="store", type=str, default=None, help="Token necessary to access skills.") -# content of conftest.py -def pytest_configure(config) -> None: - worker_id = os.environ.get("PYTEST_XDIST_WORKER") - if worker_id is not None: - os.makedirs("build/logs", exist_ok=True) - logging.basicConfig( - format=config.getini("log_file_format"), - filename=f"build/logs/tests_{worker_id}.log", - level=config.getini("log_file_level"), - ) - - -def is_git_lfs_pointer(file_path: Path) -> bool: - """Check if a file is a git LFS pointer file""" - try: - with open(file_path) as f: - first_line = f.readline().strip() - return first_line == "version https://git-lfs.github.com/spec/v1" - except Exception: - return False - - -@pytest.hookimpl(hookwrapper=True) -def pytest_runtest_makereport(item, call): - outcome = yield - report = outcome.get_result() - - if report.when == "call" and report.failed: - if "NodeJS or npm is not installed" in str(report.longrepr): - msg = "This test requires NodeJS and npm to be installed. Please install them before running the tests." - raise RuntimeError(msg) - - -@pytest.fixture(autouse=True) -def skip_lfs_tests(request) -> None: - """Skip tests that depend on git LFS files if they haven't been pulled""" - # Lets not run if we are in CI - if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true": - return - - # Get the test module path - test_path = Path(request.module.__file__) - - # Only run for integration tests - try: - cwd = Path.cwd() - except FileNotFoundError: - return - if not str(test_path).startswith(str(cwd / "tests" / "integration")): - return - - try: - expected = request.getfixturevalue("expected") - if isinstance(expected, Path) and is_git_lfs_pointer(expected): - pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled") - except Exception: - pass +# # content of conftest.py +# def pytest_configure(config) -> None: +# worker_id = os.environ.get("PYTEST_XDIST_WORKER") +# if worker_id is not None: +# os.makedirs("build/logs", exist_ok=True) +# logging.basicConfig( +# format=config.getini("log_file_format"), +# filename=f"build/logs/tests_{worker_id}.log", +# level=config.getini("log_file_level"), +# ) + + +# def is_git_lfs_pointer(file_path: Path) -> bool: +# """Check if a file is a git LFS pointer file""" +# try: +# with open(file_path) as f: +# first_line = f.readline().strip() +# return first_line == "version https://git-lfs.github.com/spec/v1" +# except Exception: +# return False + + +# @pytest.hookimpl(hookwrapper=True) +# def pytest_runtest_makereport(item, call): +# outcome = yield +# report = outcome.get_result() + +# if report.when == "call" and report.failed: +# if "NodeJS or npm is not installed" in str(report.longrepr): +# msg = "This test requires NodeJS and npm to be installed. Please install them before running the tests." +# raise RuntimeError(msg) + + +# @pytest.fixture(autouse=True) +# def skip_lfs_tests(request) -> None: +# """Skip tests that depend on git LFS files if they haven't been pulled""" +# # Lets not run if we are in CI +# if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true": +# return + +# # Get the test module path +# test_path = Path(request.module.__file__) + +# # Only run for integration tests +# try: +# cwd = Path.cwd() +# except FileNotFoundError: +# return +# if not str(test_path).startswith(str(cwd / "tests" / "integration")): +# return + +# try: +# expected = request.getfixturevalue("expected") +# if isinstance(expected, Path) and is_git_lfs_pointer(expected): +# pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled") +# except Exception: +# pass From d41bef489516e6154ddf259b98257d8132141abc Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 13:18:26 -0800 Subject: [PATCH 07/12] update conftest.py --- tests/conftest.py | 95 +++++++++++++++--------------- tests/unit/codegen/cli/conftest.py | 12 ++-- 2 files changed, 55 insertions(+), 52 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 8637e99fe..c6b200705 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,7 @@ import os +from pathlib import Path + +import pytest from tests.shared.codemod.models import Size @@ -63,7 +66,7 @@ def pytest_addoption(parser) -> None: parser.addoption("--cli-api-key", action="store", type=str, default=None, help="Token necessary to access skills.") -# # content of conftest.py +# content of conftest.py # def pytest_configure(config) -> None: # worker_id = os.environ.get("PYTEST_XDIST_WORKER") # if worker_id is not None: @@ -75,48 +78,48 @@ def pytest_addoption(parser) -> None: # ) -# def is_git_lfs_pointer(file_path: Path) -> bool: -# """Check if a file is a git LFS pointer file""" -# try: -# with open(file_path) as f: -# first_line = f.readline().strip() -# return first_line == "version https://git-lfs.github.com/spec/v1" -# except Exception: -# return False - - -# @pytest.hookimpl(hookwrapper=True) -# def pytest_runtest_makereport(item, call): -# outcome = yield -# report = outcome.get_result() - -# if report.when == "call" and report.failed: -# if "NodeJS or npm is not installed" in str(report.longrepr): -# msg = "This test requires NodeJS and npm to be installed. Please install them before running the tests." -# raise RuntimeError(msg) - - -# @pytest.fixture(autouse=True) -# def skip_lfs_tests(request) -> None: -# """Skip tests that depend on git LFS files if they haven't been pulled""" -# # Lets not run if we are in CI -# if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true": -# return - -# # Get the test module path -# test_path = Path(request.module.__file__) - -# # Only run for integration tests -# try: -# cwd = Path.cwd() -# except FileNotFoundError: -# return -# if not str(test_path).startswith(str(cwd / "tests" / "integration")): -# return - -# try: -# expected = request.getfixturevalue("expected") -# if isinstance(expected, Path) and is_git_lfs_pointer(expected): -# pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled") -# except Exception: -# pass +def is_git_lfs_pointer(file_path: Path) -> bool: + """Check if a file is a git LFS pointer file""" + try: + with open(file_path) as f: + first_line = f.readline().strip() + return first_line == "version https://git-lfs.github.com/spec/v1" + except Exception: + return False + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_makereport(item, call): + outcome = yield + report = outcome.get_result() + + if report.when == "call" and report.failed: + if "NodeJS or npm is not installed" in str(report.longrepr): + msg = "This test requires NodeJS and npm to be installed. Please install them before running the tests." + raise RuntimeError(msg) + + +@pytest.fixture(autouse=True) +def skip_lfs_tests(request) -> None: + """Skip tests that depend on git LFS files if they haven't been pulled""" + # Lets not run if we are in CI + if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true": + return + + # Get the test module path + test_path = Path(request.module.__file__) + + # Only run for integration tests + try: + cwd = Path.cwd() + except FileNotFoundError: + return + if not str(test_path).startswith(str(cwd / "tests" / "integration")): + return + + try: + expected = request.getfixturevalue("expected") + if isinstance(expected, Path) and is_git_lfs_pointer(expected): + pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled") + except Exception: + pass diff --git a/tests/unit/codegen/cli/conftest.py b/tests/unit/codegen/cli/conftest.py index 2d6421397..b664c707c 100644 --- a/tests/unit/codegen/cli/conftest.py +++ b/tests/unit/codegen/cli/conftest.py @@ -17,7 +17,11 @@ def sample_repository(tmp_path: Path): subprocess.run(["git", "config", "--local", "user.name", "Test User"], check=True) subprocess.run(["git", "commit", "--allow-empty", "-m", "Initial commit"], check=True) subprocess.run(["git", "remote", "add", "origin", "https://github.com/test/test.git"], check=True) - return tmp_path + yield tmp_path + try: + shutil.rmtree(tmp_path) + except FileNotFoundError: + pass @pytest.fixture() @@ -31,8 +35,4 @@ def initialized_repo(sample_repository: Path, runner: CliRunner): runner.invoke(init_command) subprocess.run(["git", "add", "."], cwd=sample_repository, check=True) subprocess.run(["git", "commit", "-m", "Initialize codegen"], cwd=sample_repository, check=True) - yield sample_repository - try: - shutil.rmtree(sample_repository) - except FileNotFoundError: - pass + return sample_repository From c7a6014a08085a6c8d11cec73154946335a791ac Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 13:28:47 -0800 Subject: [PATCH 08/12] Perf improvements --- src/codegen/sdk/extensions/utils.pyx | 1 + src/codegen/sdk/python/file.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/codegen/sdk/extensions/utils.pyx b/src/codegen/sdk/extensions/utils.pyx index d46a377bc..e95b69ef4 100644 --- a/src/codegen/sdk/extensions/utils.pyx +++ b/src/codegen/sdk/extensions/utils.pyx @@ -54,6 +54,7 @@ def find_all_descendants(node: TSNode, type_names: Iterable[str] | str, max_dept def iter_all_descendants(node: TSNode, type_names: Iterable[str] | str, max_depth: int | None = None, nested: bool = True) -> Generator[TSNode, None, None]: if isinstance(type_names, str): type_names = [type_names] + type_names = frozenset(type_names) def traverse(current_node: TSNode, depth=0): if max_depth is not None and depth > max_depth: diff --git a/src/codegen/sdk/python/file.py b/src/codegen/sdk/python/file.py index 4a38f4e06..36595e165 100644 --- a/src/codegen/sdk/python/file.py +++ b/src/codegen/sdk/python/file.py @@ -56,7 +56,7 @@ def symbol_can_be_added(self, symbol: PySymbol) -> bool: @noapidoc @commiter def _parse_imports(self) -> None: - for import_node in iter_all_descendants(self.ts_node, {"import_statement", "import_from_statement", "future_import_statement"}): + for import_node in iter_all_descendants(self.ts_node, frozenset({"import_statement", "import_from_statement", "future_import_statement"})): PyImportStatement(import_node, self.node_id, self.G, self.code_block, 0) #################################################################################################################### From 56066cb770e7771b8f24e9e71d637d7833b79446 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 13:32:00 -0800 Subject: [PATCH 09/12] patch out venv --- pyproject.toml | 2 +- tests/unit/codegen/cli/conftest.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d74463475..f24df39ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,7 +200,7 @@ log_cli_level = "INFO" xfail_strict = true junit_duration_report = "call" junit_logging = "all" - +tmp_path_retention_policy = "failed" [build-system] requires = ["hatchling>=1.26.3", "hatch-vcs>=0.4.0", "setuptools-scm>=8.0.0"] build-backend = "hatchling.build" diff --git a/tests/unit/codegen/cli/conftest.py b/tests/unit/codegen/cli/conftest.py index b664c707c..021975826 100644 --- a/tests/unit/codegen/cli/conftest.py +++ b/tests/unit/codegen/cli/conftest.py @@ -2,11 +2,13 @@ import shutil import subprocess from pathlib import Path +from unittest.mock import patch import pytest from click.testing import CliRunner from codegen.cli.commands.init.main import init_command +from codegen.cli.workspace.venv_manager import VenvManager @pytest.fixture @@ -32,7 +34,10 @@ def runner(): @pytest.fixture def initialized_repo(sample_repository: Path, runner: CliRunner): os.chdir(sample_repository) - runner.invoke(init_command) + + with patch.object(VenvManager, "is_initialized", return_value=True): + runner.invoke(init_command) subprocess.run(["git", "add", "."], cwd=sample_repository, check=True) subprocess.run(["git", "commit", "-m", "Initialize codegen"], cwd=sample_repository, check=True) + return sample_repository From 7b54a48b9b54a460fe8a428c80b1fa0c1c029af0 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 13:41:31 -0800 Subject: [PATCH 10/12] Move CLI testing to integration tests --- tests/{unit => integration}/codegen/cli/conftest.py | 0 tests/{unit => integration}/codegen/cli/test_reset.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{unit => integration}/codegen/cli/conftest.py (100%) rename tests/{unit => integration}/codegen/cli/test_reset.py (100%) diff --git a/tests/unit/codegen/cli/conftest.py b/tests/integration/codegen/cli/conftest.py similarity index 100% rename from tests/unit/codegen/cli/conftest.py rename to tests/integration/codegen/cli/conftest.py diff --git a/tests/unit/codegen/cli/test_reset.py b/tests/integration/codegen/cli/test_reset.py similarity index 100% rename from tests/unit/codegen/cli/test_reset.py rename to tests/integration/codegen/cli/test_reset.py From 5f8449982d755bdf7fd959cb696f0ed8a95b8436 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 13:42:30 -0800 Subject: [PATCH 11/12] Refactor conftest --- tests/conftest.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c6b200705..771e04a9e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -99,13 +99,15 @@ def pytest_runtest_makereport(item, call): raise RuntimeError(msg) -@pytest.fixture(autouse=True) +# Lets not run if we are in CI + + +IS_CI = os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true" + + +@pytest.fixture(autouse=IS_CI) def skip_lfs_tests(request) -> None: """Skip tests that depend on git LFS files if they haven't been pulled""" - # Lets not run if we are in CI - if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true": - return - # Get the test module path test_path = Path(request.module.__file__) From 1e55222c7c605142e4b2536590bf644fb2767fe6 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 13:47:06 -0800 Subject: [PATCH 12/12] Skip test for now --- tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py b/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py index 3a8ebf689..9ac955db6 100644 --- a/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py +++ b/tests/unit/codegen/sdk/benchmark/codebase/test_codebase_reset.py @@ -36,6 +36,7 @@ def setup(): benchmark.pedantic(reset_codebase, setup=setup) +@pytest.mark.skip("Skipping this test for now") @pytest.mark.timeout(5, func_only=True) @pytest.mark.parametrize("extension", ["txt", "py"]) def test_codebase_reset_correctness(extension: str, tmp_path):