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

No longer suggesting type alias as import #6799

Closed
ManiMozaffar opened this issue Dec 25, 2024 · 3 comments
Closed

No longer suggesting type alias as import #6799

ManiMozaffar opened this issue Dec 25, 2024 · 3 comments

Comments

@ManiMozaffar
Copy link

ManiMozaffar commented Dec 25, 2024

I'm having the same issue as #6567 , not sure why that was closed! And downgrading to PyLance 2024.9.2 would solve the issue for me.
I couldn't re-open the issue, that issue has every necessary information to reproduce.

Behaviour

Python no longer suggests type aliases from the project

Steps to reproduce:

Create type alias like this (TypeAlias type annotation doesn't matter): Component: TypeAlias = VdomDict | ReactpyComponent | ContextProviderType | str

Go to some other file in the project and try ctrl + . to try to import it. It is not an option. It is not an option under "search for other import matches". Adding a class to the same file shows up. If you search for the name with ctrl + t it shows up as the first option.

If I enable "enable aliases in user files", it still does not show up.

I created a fresh codespace to rule out some sort of corruption somewhere.

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.4
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): UV
  • Value of the python.languageServer setting: Default
@nbro10
Copy link

nbro10 commented Jan 2, 2025

In my case, I have a project with 3 sibling packages and only one pyproject.toml (in the root directory), which specifies that I have the 3 packages using something like this (I'm using Poetry)

packages = [
    { include = "pkg_a", from = "." },
    { include = "pkg_b", from = "." },
    { include = "pkg_c", from = "." },
]

Now, from pkg_a, I can import a class from pkg_b and pylance autosuggest that, but I cannot indeed import an alias defined in the same module/file as the class that pylance is able to suggest to import.

@rchiodo
Copy link
Contributor

rchiodo commented Jan 6, 2025

I believe this issue is a duplicate:

#6601

Type aliases are currently considered exports because they're considered variables and variables aren't considered as exports. We hope to change this though.

@rchiodo rchiodo closed this as completed Jan 6, 2025
@ManiMozaffar
Copy link
Author

ManiMozaffar commented Jan 6, 2025

I believe this issue is a duplicate:

#6601

Type aliases are currently considered exports because they're considered variables and variables aren't considered as exports. We hope to change this though.

Not quite same, because any type declaration has stopped to appear as suggestion on my vscode since that update, not just newtype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants