Fix PathEntryFinder / MetaPathFinder in editable_wheel#4278
Fix PathEntryFinder / MetaPathFinder in editable_wheel#4278abravalheri merged 4 commits intopypa:mainfrom
PathEntryFinder / MetaPathFinder in editable_wheel#4278Conversation
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
| 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.
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.
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
generatorvscoroutineis weird... Here I meancoroutineas in other languages, without the weirdasyncthat ended up messed in the Python concepts. ↩
There was a problem hiding this comment.
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
PathEntryFinderwhen trying to locate nested namespaces, if thesys.path_hookitem corresponding to the finder cannot be located in the submodule locations of the parent namespace.Summary of changes
We should (probably) add the
PATH_PLACEHOLDERto the namespace spec , so that thePathEntryFinderis 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)