Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(A005): support detecting a shadowing folder #125

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion flake8_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading