diff --git a/CHANGES.rst b/CHANGES.rst index 66466cc..c38c9a7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,8 @@ Changelog 2.4.1 (unreleased) ------------------ -- Nothing changed yet. +- Support detecting a shadowing folder as module name (as part of `A005`). + [asfaltboy] 2.4.0 (2024-04-01) diff --git a/flake8_builtins.py b/flake8_builtins.py index 1b3ef4f..e95d1db 100644 --- a/flake8_builtins.py +++ b/flake8_builtins.py @@ -293,7 +293,10 @@ def check_module_name(self, filename: str): if not self.module_names: return path = Path(filename) - module_name = path.name.removesuffix('.py') + if path.name == '__init__.py': + module_name = path.parent.name + else: + module_name = path.name.removesuffix('.py') if module_name in self.module_names: yield self.error( None, diff --git a/run_tests.py b/run_tests.py index 057d356..26064e0 100644 --- a/run_tests.py +++ b/run_tests.py @@ -510,6 +510,7 @@ def test_tuple_unpacking(): def test_module_name(): source = '' check_code(source, expected_codes='A005', filename='./temp/logging.py') + check_code(source, expected_codes='A005', filename='./temp/typing/__init__.py') @pytest.mark.skipif(