From 74588e17d8118cd270a4cf510742656a5ca15192 Mon Sep 17 00:00:00 2001 From: Pavel savchenko Date: Mon, 8 Apr 2024 13:54:15 +0100 Subject: [PATCH 1/2] feat(A005): support detecting a shadowing folder fix #124 --- flake8_builtins.py | 5 ++++- run_tests.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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( From b46b4d7b80c1fdeff51ea46b604e0312debda999 Mon Sep 17 00:00:00 2001 From: Pavel savchenko Date: Tue, 9 Apr 2024 11:19:17 +0100 Subject: [PATCH 2/2] chore: add change note for shadow dir module --- CHANGES.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)