Describe the bug
pyright reports "xxx is not a known member of module" for no reason.
To Reproduce
import torch
torch.__version__
Expected behavior
No error/warning.
Screenshots or Code

VS Code extension or command-line
VS Code extension v1.0.75
Additional context
VSCode 1.40.0 insider
This appears to be a problem with the type stub file that ships with pytorch. It doesn't include the __version__ symbol. It is up to library authors to determine what symbols they want to export as part of the official interface contract, and those symbols must be defined in the typestub file. I recommend that you file a bug or submit a PR with the pytorch library.
ahh I see, thanks.
The fix is simple. Just add the line __version__: str to the __init__.pyi that ships with pytorch.
This error also occurs with many other common imports such as json.loads is there a way to ignore this?
also with numpy:
np.sqrt(...)
np.asarray(col)
{
"resource": "...",
"owner": "_generated_diagnostic_collection_name_#1",
"severity": 8,
"message": "\"asarray\" is not a known member of module",
"source": "Pylance (reportGeneralTypeIssues)",
"startLineNumber": 59,
"startColumn": 26,
"endLineNumber": 59,
"endColumn": 33
}
If you are using a type stub for the library and you believe that the stub is missing a symbol, report the problem (or submit a PR) with the maintainer of that type stub.
If you are not using a type stub and are instead relying on the "useLibraryCodeForTypes" setting, type information extracted from source code will be incomplete and can result in spurious errors. This is why it's so important to use high-quality type stubs for libraries you consume.