Skip to content
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

Remove auto-import when typing the letter d to avoid being serenaded with The Zen of Python #2535

Closed
hgibling opened this issue Apr 5, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version P2

Comments

@hgibling
Copy link

hgibling commented Apr 5, 2022

Hello,

After a lot of head scratching as to why my python script was suddenly reciting The Zen of Python this afternoon, I learned it was because my code had from this import d added to the top. I did not type that though.

After more head scratching I learned it was because I had typed a single letter d and accidentally hit enter before finishing my variable. Capital D triggers this as well.

I see how the auto-import functions are useful, but since this particular case adds a module that outputs a lengthy poem, perhaps this can be disabled, or more text can be required, or there can be a two-step confirmation process? It has bungled up at least one other person.

@github-actions github-actions bot added the triage label Apr 5, 2022
@judej judej added needs investigation Could be an issue - needs investigation P2 labels Apr 5, 2022
@github-actions github-actions bot removed the triage label Apr 5, 2022
@bschnurr bschnurr self-assigned this Apr 5, 2022
@debonte
Copy link
Contributor

debonte commented Apr 5, 2022

This is both hysterical and very annoying. :)

this.py is part of the stdlib that was added as an Easter egg in PEP 20.

@heejaechang, perhaps we should ban this.py from auto-import? Or maybe we should never offer auto-imports for single letter identifiers?

@bschnurr
Copy link
Member

bschnurr commented Apr 5, 2022

should we also suggest adding '_' to the front of those variables in https://github.com/python/cpython/blob/main/Lib/this.py

@hgibling
Copy link
Author

hgibling commented Apr 5, 2022

This is both hysterical and very annoying. :)

Had this occurred 3 days prior I would have assumed it was an April Fool's joke!

@bschnurr bschnurr added enhancement New feature or request and removed needs investigation Could be an issue - needs investigation labels Jun 9, 2022
@casellimarco
Copy link

Would it be possible to add the option to "whitelist" some packages in python.analysis.autoImportCompletions? For instance, when I use pdb.set_trace() I don't want it to go on the top of the file if I have forgotten to import it before

@debonte
Copy link
Contributor

debonte commented Apr 12, 2023

For this issue and #4229, we should exclude Easter egg stdlib modules from auto-import. Are there more than this and antigravity?

@heejaechang
Copy link
Contributor

user can use python.analysis.packageIndexDepths to disable those if they want by giving the packate search depth 0

ex)

"name": "this",
"depth": 0

that said, I think it is good idea to filter them out from our indices at the first place.

@bschnurr bschnurr added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Apr 27, 2023
@rchiodo
Copy link
Contributor

rchiodo commented May 4, 2023

This issue has been fixed in prerelease version 2023.5.11, which we've just released. You can find the changelog here: CHANGELOG.md

@rchiodo rchiodo closed this as completed May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version P2
Projects
None yet
Development

No branches or pull requests

7 participants