Skip to content

Commit

Permalink
Merge pull request #125 from asfaltboy/ps/import-a005-module-dir
Browse files Browse the repository at this point in the history
feat(A005): support detecting a shadowing folder
  • Loading branch information
gforcada authored Apr 9, 2024
2 parents 5b6dbff + b46b4d7 commit 3890afb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit 3890afb

Please sign in to comment.