You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pylance is still aware this is incorrect on some level and immediately flags the Any tokens with reportAttributeAccessIssue.
On the other hand, Ctrl+Clicking on the Any token takes me to vscode\extensions\ms-python.vscode-pylance-2024.10.1\dist\typeshed-fallback\stdlib\typing.pyi, indicating that it does have some idea where Any actually comes from.
The same issue occurs when double clicking on some inlays that suggest the Any type. In this example, the return type on baz is the result of double clicking an inlay hint that was rendered as -> Any | None.
I was only able to trigger the bug on an inlay when the Any type was originating from outside my code and was part of a union type with something else. Removing the condition or using some locally created value that identifies as dict[str, any] causes pylance to instead insert a comment of the type annotation without any module names.
Speculation
This issue isn't specific to the os module, but it doesn't trigger for all modules. It seems to me that the issue occurs when the pyi file for any imported module itself imports Any from typing. Since pylance will take me to typing.pyi when I click on the token, I can only assume that pylance knows perfectly well what module Any actually comes from, but it is somehow being associated with the namespace it is first imported into when it comes time to format the type for insertion in my code.
Previously I was getting this error even without any import statements, but in the course of debugging I deleted ms-python.vscode-pylance-2024.10.1\dist\.cache and reinstalled the extension. After these steps, it began correctly attributing the Any type to typing as long as no problematic modules were imported, but as you can see all is still not well.
Apologies if this is already known. I searched around the issues and I found some type annotation related stuff (hence why I tried disabling A/B testing) but nothing jumped out as this problem specifically.
Environment data
Settings.json
I'm running Python in a venv with no external modules present:
Repro Steps
Entering this code:
and then triggering the suggested completion for
__call__
Expected behavior
I would anticipate either of the two following outputs:
or at the very least:
Actual behavior
Pylance incorrectly attributes
Any
to theos
module, or some other module if it is imported beforeos
.Pylance is still aware this is incorrect on some level and immediately flags the
Any
tokens withreportAttributeAccessIssue
.On the other hand, Ctrl+Clicking on the
Any
token takes me tovscode\extensions\ms-python.vscode-pylance-2024.10.1\dist\typeshed-fallback\stdlib\typing.pyi
, indicating that it does have some idea whereAny
actually comes from.The same issue occurs when double clicking on some inlays that suggest the
Any
type. In this example, the return type on baz is the result of double clicking an inlay hint that was rendered as-> Any | None
.I was only able to trigger the bug on an inlay when the
Any
type was originating from outside my code and was part of a union type with something else. Removing the condition or using some locally created value that identifies asdict[str, any]
causes pylance to instead insert a comment of the type annotation without any module names.Speculation
This issue isn't specific to the os module, but it doesn't trigger for all modules. It seems to me that the issue occurs when the pyi file for any imported module itself imports
Any
fromtyping
. Since pylance will take me to typing.pyi when I click on the token, I can only assume that pylance knows perfectly well what moduleAny
actually comes from, but it is somehow being associated with the namespace it is first imported into when it comes time to format the type for insertion in my code.Previously I was getting this error even without any import statements, but in the course of debugging I deleted
ms-python.vscode-pylance-2024.10.1\dist\.cache
and reinstalled the extension. After these steps, it began correctly attributing theAny
type totyping
as long as no problematic modules were imported, but as you can see all is still not well.Apologies if this is already known. I searched around the issues and I found some type annotation related stuff (hence why I tried disabling A/B testing) but nothing jumped out as this problem specifically.
pylance_2024.10.1_id_0.txt
The text was updated successfully, but these errors were encountered: