-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix #5758 -- plain import didn't work with namespace package #5762
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
Conversation
So here's a fix for part two of #5758. The way it works is, first, when But that's not all that's needed! @macbeth322 -- you were spot on with your suggestion that this had something to do with the ancestor dependencies in This order dependency is ugly and caused a bunch of tests to fail (since the errors about missing packages come out in a different order) but it's the best I could come up with.
|
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.
Looks good, with one comment request and one test request.
If the test request is super painful then it is probably OK to skip for now if we need to cherry-pick this, but it seems like the sort of thing that is super easy to break later, so.
@@ -572,12 +572,12 @@ def correct_rel_imp(imp: Union[ImportFrom, ImportAll]) -> str: | |||
pri = import_priority(imp, PRI_MED) | |||
ancestor_pri = import_priority(imp, PRI_LOW) | |||
for id, _ in imp.ids: | |||
res.append((pri, id, imp.line)) |
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 somewhat subtle order dependency might deserve some comment.
# installed package with a py.typed marker that is a | ||
# subpackage of a namespace package. We only fess up to these | ||
# if we would otherwise return "not found". | ||
return self.ns_ancestors.get(id) |
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.
Is it possible to add a test for this case?
Added a comment. I believe adding a test for this situation would require adding a big chunk of code to testpep561.py. I'd rather focus on other aspects of the release, but I'll file a bug to remind myself. |
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.
Looks good! I think it is fine to add the test later.
No description provided.