-
Notifications
You must be signed in to change notification settings - Fork 771
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
Support auto-import on snake_cased varaiables. #703
Comments
Recently I'm trying very hard to make all of my colleague move from PyCharm to VSCode, but the auto-import related behaviours in VSCode are pushing them back to PyCharm. According to my own experience, PyCharm is actually not doing a very good job about auto-import, but it have a well-implemented "manual import" actions, which uses a much aggresive stratege and searches all the possible match through the whole project and you can always find what you want even these action may take longer to complete. Even it might takes 3~5s to resolve import candidates in our project, it's still much faster than manually write those imports by hand. I think auto-import is a feature that very hard to tweak, so maybe adding an "manual import" action that use a slow but "searches everything" stratege like PyCharm is a good way to go, because it can make sure everyone get what they want to import eventually. |
@judej, thanks for your reply. I've tried the insiders version but snake_cased variables are still can't be auto imported. Not sure if I did anything wrong, my Pylance version looks like this: And I also tried the But the workspace symbol search is functioning though, not sure If that proves the indexer is working. |
@giyyapan we explicitly filtering out lower case variables from the auto-import, that is why you are not seeing it. we are doing it since it bloats the completion list too much if we include all lower variables defined blindly. I like this idea
but not sure whether we want to show it in auto-import or "add import (code action/light bulb)" only. unlike code action, auto-import can interfere with typing, so if we can, we don't want to add more entries in the completion. |
this is now fixed and lower case variable in db will show up in code action. |
We have some flask apps that creates instances in a file and import it from other files. Please see the example:
In base.py
In api.py
Pylance's auto-import now suggests Classes, functions, UPPER_SNAKE_CASED variables, but no lower_snake_cased variables (like
db
). This would be a big problem for our code style (and this is a commonly used code style for flask users), and we'd have to manually write tons for imports by hand!We tried to put those variables we'd like to import from other files into the
__all__
list, but Pylance seems to ignoring it.I assume this is an as-designed behaviour because I can image others might say this is the correct behaviour, but it makes us very hard to adapt using our current code base.
So I wish Pylance can have one of these improvements:
__all__
variable (or some other magic variable that indicates which variable we would like to export).Thanks!
The text was updated successfully, but these errors were encountered: