-
Notifications
You must be signed in to change notification settings - Fork 8
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: check for both path/foo.py and path/foo/__init__.py being present #39
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to add a section to the README
describing the new check, when it fails, why it's a problem, and/or how to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing with actual wheels is only for special cases, and there generally isn't a need to add more test wheels at this time. Instead, the new check should be tested with a test function in test/test_checking.py
that just operates on lists of filepaths; cf. the tests already in that file and the "Adding a New Check" section of CONTRIBUTING.md
.
Please remove this wheel from your PR's history before requesting a re-review.
@@ -23,6 +23,7 @@ class Check(Enum): | |||
W008 = "Wheel is empty" | |||
W009 = "Wheel contains multiple toplevel library entries" | |||
W010 = "Toplevel library directory contains no Python modules" | |||
W011 = "Wheel contains module and submodule with the same name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W011 = "Wheel contains module and submodule with the same name" | |
W011 = "Wheel contains module and package with the same basename" |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of returning a single failed check that just contains the conflicting directory paths, I feel you should instead return one FailedCheck
for each foo.py
+ foo/__init__.py
pair, and the FailedCheck
should contains both of those paths.
Cf. the following paragraph from "Adding a New Check" in CONTRIBUTING.md
:
Generally, a check method should return at most one
FailedCheck
containing all of the failing filepaths; only return multipleFailedCheck
s if the check applies to groups of files. For example, W002 ("Wheel contains duplicate files") returns a separateFailedCheck
for each group of equal files.
for name, entry in tree.entries.items(): | ||
if isinstance(entry, Directory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for name, entry in tree.entries.items(): | |
if isinstance(entry, Directory): | |
for name, entry in tree.subdirectories.items(): |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conflicts.append(entry.path or name) | |
# `entry` exists within a directory and thus is not the root directory, and so it has a path. | |
assert entry.path is not None | |
conflicts.append(entry.path) |
check_dir(entry) | ||
|
||
for tree in (contents.purelib_tree, contents.platlib_tree): | ||
if isinstance(tree, Directory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is redundant; contents.purelib_tree
and contents.platlib_tree
are always Directory
s.
Hey 👋
Quick MR to close #19
As it's my first contribution here, I'm happy to take any feedback, especially around the wording of the rule.
I've included a wheel for E2E testing, but will try to add more tests if needed.
Thanks,
Gabriel