-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-69605: Check for already imported modules in PyREPL module completion #139461
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
base: main
Are you sure you want to change the base?
gh-69605: Check for already imported modules in PyREPL module completion #139461
Conversation
Ok, one of the new test fails on Windows x64/32 (but pass on arm) I just setup and built Python on a Win 11 x64 to try to reproduce, the test pass 😵💫 (and the fix works) |
I'm going to convert it into a draft until you deem this PR ready. That will also reduce the probability of someone clicking on the PR to review it (like me...) while it's not yet ready for. |
Thanks, I just fixed the failing test, this should be ready for review! Sorry again for the noise, I was dealing with what turned out to be a importer cache issue, which I couldn't reproduce outside of the CI buildbots 😓 [edit] I just noticed I can convert to draft / mark ready myself, will do it next times! |
…ules' of https://github.com/loic-simon/cpython into pyrepl-module-completion-check-for-already-imported-modules
This PR handles an edge-case when suggesting module imports in PyREPL (see this comment):
If a module is already imported, the import machinery will only get submodules from it, even if a module of the same name is higher in the path. This can happen if eg. sys.path has been updated since the module was originaly imported.
The easiest way to reproduce this issue (and how I stumbled on it) is with stdlib modules imported during interpreter startup (before site customisation, so ignoring potential shadowing):
This PR add a special case in
_pyrepl.ModuleCompleter._find_modules
thatIt was a little tricky to get right, I'm not sure about everything 😅 but it pass all tests I could think off!
cc @tomasr8