diff --git a/CHANGELOG.md b/CHANGELOG.md index 73ac136ec..2295ff0e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### 🐛 Bug fixes +- Fixed issue in `static-type-checker` such that mypy no longer checks imported modules in the file being checked + ### 🔧 Internal changes - Configured CI tests to run on environments with and without `z3` dependency. diff --git a/examples/custom_checkers/static_type_checker_examples/imports_no_error.py b/examples/custom_checkers/static_type_checker_examples/imports_no_error.py new file mode 100644 index 000000000..4b02e9791 --- /dev/null +++ b/examples/custom_checkers/static_type_checker_examples/imports_no_error.py @@ -0,0 +1,2 @@ +# Imports a module with mypy errors, but mypy should not report any errors when checking this file +import e9952_incompatible_assignment diff --git a/python_ta/checkers/static_type_checker.py b/python_ta/checkers/static_type_checker.py index 1c2af7466..82617e78e 100644 --- a/python_ta/checkers/static_type_checker.py +++ b/python_ta/checkers/static_type_checker.py @@ -73,10 +73,7 @@ class StaticTypeChecker(BaseRawFileChecker): def process_module(self, node: nodes.NodeNG) -> None: """Run Mypy on the current file and handle type errors.""" filename = node.stream().name - mypy_options = [ - "--ignore-missing-imports", - "--show-error-end", - ] + mypy_options = ["--ignore-missing-imports", "--show-error-end", "--follow-imports=skip"] result, _, _ = api.run([filename] + mypy_options) for line in result.splitlines(): diff --git a/tests/test_custom_checkers/test_static_type_checker.py b/tests/test_custom_checkers/test_static_type_checker.py index d523db7e9..afd0bb530 100644 --- a/tests/test_custom_checkers/test_static_type_checker.py +++ b/tests/test_custom_checkers/test_static_type_checker.py @@ -217,3 +217,15 @@ def test_no_errors_in_static_type_checker_no_error(self) -> None: mod = MANAGER.ast_from_file(file_path) with self.assertNoMessages(): self.checker.process_module(mod) + + def test_imports_no_error(self) -> None: + """Imports a module with mypy errors, no errors raised.""" + file_path = os.path.normpath( + os.path.join( + __file__, + "../../../examples/custom_checkers/static_type_checker_examples/imports_no_error.py", + ) + ) + mod = MANAGER.ast_from_file(file_path) + with self.assertNoMessages(): + self.checker.process_module(mod)