-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix PathEntryFinder
/ MetaPathFinder
in editable_wheel
#4278
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
e2e2b79
to
8293a81
Compare
88e40e2
to
c540312
Compare
It seems that the import machinery skips PathEntryFinder when trying to locate nested namespaces, if the `sys.path_hook` item corresponding to the finder cannot be located in the submodule locations of the parent namespace. This means that we should probably always add the PATH_PLACEHOLDER to the namespace spec. This PR also add some type hints to the template, because it helped to debug some type errors.
c540312
to
2b7ea60
Compare
@@ -530,11 +530,20 @@ def __call__(self, wheel: "WheelFile", files: List[str], mapping: Dict[str, str] | |||
|
|||
name = f"__editable__.{self.name}.finder" | |||
finder = _normalization.safe_identifier(name) | |||
return finder, name, mapping, namespaces_ | |||
|
|||
def get_implementation(self) -> Iterator[Tuple[str, bytes]]: |
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.
Why hide the true type of Generator[tuple[str, bytes], None, None]
here? Is there a reason for only wanting to interact with an Iterator
?
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.
My personal opinion is that Generator[tuple[str, bytes], None, None]
is a beast/convoluted to understand...
Iterator[Tuple[str, bytes]]
is clearer and the reader can get immediately how they are supposed use/call the function.
(also, we don't use the "coroutine" abilities of the "generator"1, i.e. there is no generator.send
, so I don't think is relevant to have the explicit generator type there).
Footnotes
-
Python nomenclature with the
generator
vscoroutine
is weird... Here I meancoroutine
as in other languages, without the weirdasync
that ended up messed in the Python concepts. ↩
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.
Thanks! Just double checking the intention since I'll need to update the typeshed stubs for version 70
It seems that the import machinery skips
PathEntryFinder
when trying to locate nested namespaces, if thesys.path_hook
item corresponding to the finder cannot be located in the submodule locations of the parent namespace.Summary of changes
We should (probably) add the
PATH_PLACEHOLDER
to the namespace spec , so that thePathEntryFinder
is triggered.This PR also add some type hints to the template, because it helped to debug some type errors.
Closes #4248 (likely)
Pull Request Checklist
newsfragments/
.(See documentation for details)