Skip to content

Commit

Permalink
feat: module shadow (fix jwodder#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabDug committed Mar 27, 2024
1 parent 86664a3 commit d4816fd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/check_wheel_contents/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,29 @@ def check_W010(self, contents: WheelContents) -> list[FailedCheck]:
else:
return []

def check_W011(self, contents: WheelContents) -> list[FailedCheck]:
"""
W011 — Conflict between module as a file (.py) and as a folder (__init__.py)
Checks for both `path/foo.py` and `path/foo/__init__.py` being present
"""
conflicts: list[str] = []

def check_dir(tree: Directory) -> None:
for name, entry in tree.entries.items():
if isinstance(entry, Directory):
if tree.files.get(name + ".py") is not None:
conflicts.append(entry.path or name)
check_dir(entry)

for tree in (contents.purelib_tree, contents.platlib_tree):
if isinstance(tree, Directory):
check_dir(tree)

if conflicts:
return [FailedCheck(Check.W011, conflicts)]
return []

def check_W101(self, contents: WheelContents) -> list[FailedCheck]:
"""
W101 — Wheel library is missing files in package tree
Expand Down
1 change: 1 addition & 0 deletions src/check_wheel_contents/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Check(Enum):
W102 = "Wheel library contains files not in package tree"
W201 = "Wheel library is missing specified toplevel entry"
W202 = "Wheel library has undeclared toplevel entry"
W011 = "Wheel library has multiple declared toplevel entries"


@attr.s(auto_attribs=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"stdout": "module_file_folder_shadow-0.1.0-py3-none-any.whl: W011: Wheel library has multiple declared toplevel entries:\n module_file_folder_shadow/foo/\n module_file_folder_shadow/foo/bar/",
"stderr": "",
"rc": 1
}
Binary file not shown.

0 comments on commit d4816fd

Please sign in to comment.