microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.71k stars 765 forks source link

No autocomplete suggestions for PEP 695 type aliases #6543

Open cdce8p opened 3 weeks ago

cdce8p commented 3 weeks ago

Environment data

Code Snippet

# lib.py
def my_func() -> None: ...
type MyAlias = int | str | None: ...

Repro Steps

  1. Create lib.py file
  2. In the same folder, create a test.py file and open it
  3. Look for autocomplete suggestions for both my_func and MyAlias

Expected behavior

Similar to my_func I'd have expected an autocomplete suggestion for MyAlias.

Actual behavior

No suggestion for MyAlias.

Settings

{
    "python.analysis.typeCheckingMode": "strict",
    "python.analysis.indexing": true,
    "python.analysis.includeAliasesFromUserFiles": true
}

Not sure what includeAliasesFromUserFiles actual does (i.e. which alias symbols are supposed to show up) but changing it doesn't seem to have any effect.

nmay231 commented 1 week ago

Can confirm this doesn't work. In fact, even the old style of writing type aliases (Alias = ... instead of type Alias = ...) doesn't work.

{
    "python.analysis.typeCheckingMode": "basic",
    "python.analysis.autoImportCompletions": true,
    "python.analysis.typeEvaluation.deprecateTypingAliases": true
}

@cdce8p includeAliasesFromUserFiles basically means you want to allow importing objects from modules other than where it was defined. For example, you have a module lib.py that just imports a ton of classes and functions and you want to be able to import everything from that module. Basically, this is only useful if you want a python file to act like how __init__.py works.