-
Notifications
You must be signed in to change notification settings - Fork 768
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
Display type aliases in auto-import suggestions #606
Comments
Can you clarify what you mean? Are you saying that the names themselves should appear as symbols in the workspace symbol search? We don't include these in document symbols (the outline) or workspace symbols (but I don't think we did before either). |
@jakebailey Given two files: # const.py
MyAlias = list[int]
MyConst = 42
class MyClass:
...
# main.py
var: [Alias] If I start writing -- |
Ah, my mistake. "type aliases", I took it to mean an import alias in With indexing enabled, you should get the completion for that (or, by opening up the file so it's loaded). Is it correct that you're saying it's missing? |
Yeah, at least I though so. After some further investigation I found that |
There's some heuristics to indexing to prevent it from taking too long in library code, but if this is all within user code, we should be doing a better job. |
@cdce8p yes, you are right on the heuristics. since python doesn't have a formal way (like export in typescript) to specify which variables should be accessible from others, including every variable in the auto-import causes too much noise in completion. (easily cause hundreds of more entries to be inserted into completion). so we have this heuristics but that being said, if we can come up with better heuristics, we can try that. |
I think it makes sense to include capitalized (camel-case) variables defined at the module level. These are likely type aliases. Also, I noticed that your current heuristic uses a reg-ex that is incorrect because it doesn't allow numbers or underscores. See symbolNameUtils.isConstantName for a better approach. |
@erictraut existing regExp is negative check, so it disallows any variable that contains non capital char, so it will allow number and such that is legal to identifier. It doesn't care about space and such since name already passed identifier name check. but sure, I can change it to isConstantName if that is prefered. |
This issue has been fixed in version 2020.11.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020112-18-november-2020 |
I really like the change to the auto-import suggestions (#163) introduced with the last release
2020.11.1
.However it doesn't seem like type aliases get indexed. I've already set
python.analysis.indexing
totrue
.Maybe this is a feature worth considering.
The text was updated successfully, but these errors were encountered: