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(