microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.69k stars 767 forks source link

`typing_extensions` isn't found in `<repo>/<worktree>/src/` #6150

Open nineteendo opened 1 month ago

nineteendo commented 1 month ago

Environment data

Code Snippet

repo/main/src/typing_extensions.py: typing_extensions e239100

# repo/main/src/main.py
from typing_extensions import Literal  # Import "typing_extensions" could not be resolved from source

TRUE: Literal[True] = True

Directory tree

repo
+-main
  +-src
    |-main.py
    +-typing_extensions.py

Expected behavior

No warnings, I'm bundling a version of the third-party typing_extensions module, not a module from the stdlib.

Actual behavior

Screenshot 2024-07-16 at 11 32 53

Logs

2024-07-16 11:31:57.486 [info] (Client) Pylance async client (2024.7.1) started with python extension (2024.10.0)
2024-07-16 11:31:58.495 [info] [Info  - 11:31:58] (14842) Pylance language server 2024.7.1 (pyright version 1.1.369, commit 1168be71) starting
2024-07-16 11:31:58.496 [info] [Info  - 11:31:58] (14842) Server root directory: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-16 11:31:58.504 [info] [Info  - 11:31:58] (14842) Starting service instance "repo"
2024-07-16 11:31:58.549 [info] (14842) No configuration file found.
2024-07-16 11:31:58.549 [info] (14842) No pyproject.toml file found.
2024-07-16 11:31:58.550 [info] [Info  - 11:31:58] (14842) Setting pythonPath for service "repo": "/usr/local/bin/python3"
2024-07-16 11:31:58.551 [info] [Info  - 11:31:58] (14842) Setting environmentName for service "repo": "3.12.4 (global)"
2024-07-16 11:31:58.551 [info] [Info  - 11:31:58] (14842) No include entries specified; assuming /Users/wannes/Desktop/repo
2024-07-16 11:31:58.552 [info] [Info  - 11:31:58] (14842) Auto-excluding **/node_modules
2024-07-16 11:31:58.552 [info] [Info  - 11:31:58] (14842) Auto-excluding **/__pycache__
2024-07-16 11:31:58.554 [info] [Info  - 11:31:58] (14842) Auto-excluding **/.*
2024-07-16 11:31:58.602 [info] [Info  - 11:31:58] (14842) Assuming Python version 3.12.4.final.0
2024-07-16 11:31:58.602 [info] (14842) Assuming Python platform Darwin
2024-07-16 11:31:58.683 [info] [Info  - 11:31:58] (14842) Search paths for file:///Users/wannes/Desktop/repo
2024-07-16 11:31:58.684 [info] [Info  - 11:31:58] (14842)   /Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib
2024-07-16 11:31:58.684 [info] [Info  - 11:31:58] (14842)   /Users/wannes/Desktop/repo
2024-07-16 11:31:58.684 [info] [Info  - 11:31:58] (14842)   /Users/wannes/Desktop/repo/typings
2024-07-16 11:31:58.684 [info] [Info  - 11:31:58] (14842)   /Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stubs/...
2024-07-16 11:31:58.684 [info] [Info  - 11:31:58] (14842)   /Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/bundled/stubs
2024-07-16 11:31:58.684 [info] [Info  - 11:31:58] (14842)   /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12
2024-07-16 11:31:58.685 [info] [Info  - 11:31:58] (14842)   /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload
2024-07-16 11:31:58.685 [info] [Info  - 11:31:58] (14842)   /usr/local/lib/python3.12/site-packages
2024-07-16 11:31:58.686 [info] [Info  - 11:31:58] (14842) Adding fs watcher for library directories:
 file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12
file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload
file:///usr/local/lib/python3.12/site-packages
2024-07-16 11:31:58.688 [info] [Info  - 11:31:58] (14842) Adding fs watcher for directories:
 file:///Users/wannes/Desktop/repo
2024-07-16 11:31:58.688 [info] (14842) Searching for source files
2024-07-16 11:31:58.698 [info] [Info  - 11:31:58] (14842) Found 2 source files
2024-07-16 11:31:58.701 [info] (14842) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:31:58.705 [info] (14842) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:31:58.775 [info] (14842) Attempting to resolve using local imports: __builtins__
2024-07-16 11:31:58.775 [info] (14842) Attempting to resolve using root path 'file:///Users/wannes/Desktop/repo/main/src'
2024-07-16 11:31:58.776 [info] (14842) Attempting to resolve using root path 'file:///Users/wannes/Desktop/repo/main'
2024-07-16 11:31:58.777 [info] (14842) [FG] parsing: file:///Users/wannes/Desktop/repo/main/src/main.py (59ms)
2024-07-16 11:31:58.946 [info] (14842) [FG] parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 4ms] (167ms)
2024-07-16 11:31:58.983 [info] (14842) [FG] binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/builtins.pyi (35ms)
2024-07-16 11:31:58.983 [info] (14842) [FG] binding: file:///Users/wannes/Desktop/repo/main/src/main.py (0ms)
2024-07-16 11:31:59.204 [info] [Info  - 11:31:59] (14842) Background analysis(1) root directory: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-16 11:31:59.208 [info] [Info  - 11:31:59] (14842) Background analysis(1) started
2024-07-16 11:31:59.295 [info] (14842) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:31:59.318 [info] [Info  - 11:31:59] (14842) Indexer background runner(2) root directory: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist (index)
2024-07-16 11:31:59.319 [info] [Info  - 11:31:59] (14842) Indexing(2) started
2024-07-16 11:31:59.340 [info] (14842) Attempting to resolve using local imports: __builtins__
2024-07-16 11:31:59.340 [info] (14842) Attempting to resolve using root path 'file:///Users/wannes/Desktop/repo/main/src'
2024-07-16 11:31:59.341 [info] (14842) Attempting to resolve using root path 'file:///Users/wannes/Desktop/repo/main'
2024-07-16 11:31:59.348 [info] (14842) [BG(1)] analyzing: file:///Users/wannes/Desktop/repo/main/src/main.py ...
2024-07-16 11:31:59.349 [info] (14842) [BG(1)]   parsing: file:///Users/wannes/Desktop/repo/main/src/main.py (47ms)
2024-07-16 11:31:59.430 [info] (14842) [BG(1)]   parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 5ms] (85ms)
2024-07-16 11:31:59.478 [info] (14842) [IDX(2)] scan packages file:///Users/wannes/Desktop/repo ...
2024-07-16 11:31:59.480 [info] (14842) [IDX(2)]   read stdlib indices (35ms)
2024-07-16 11:31:59.481 [info] (14842) [BG(1)]   binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/builtins.pyi (49ms)
2024-07-16 11:31:59.483 [info] (14842) [BG(1)]   binding: file:///Users/wannes/Desktop/repo/main/src/main.py (1ms)
2024-07-16 11:31:59.519 [info] (14842) [BG(1)]   checking: file:///Users/wannes/Desktop/repo/main/src/main.py ...
2024-07-16 11:31:59.520 [info] (14842) [BG(1)]     parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing.pyi [fs read 1ms] (22ms)
2024-07-16 11:31:59.529 [info] (14842) [BG(1)]     binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing.pyi (11ms)
2024-07-16 11:31:59.547 [info] (14842) [BG(1)]     parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/types.pyi [fs read 1ms] (7ms)
2024-07-16 11:31:59.555 [info] (14842) [BG(1)]     binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/types.pyi (7ms)
2024-07-16 11:31:59.573 [info] (14842) [BG(1)]     parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 1ms] (11ms)
2024-07-16 11:31:59.585 [info] (14842) [BG(1)]     binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (12ms)
2024-07-16 11:31:59.597 [info] (14842) [BG(1)]     parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/abc.pyi [fs read 0ms] (4ms)
2024-07-16 11:31:59.610 [info] (14842) [BG(1)]     binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/abc.pyi (13ms)
2024-07-16 11:31:59.661 [info] (14842) [BG(1)]     parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 0ms] (5ms)
2024-07-16 11:31:59.664 [info] (14842) [BG(1)]     binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing_extensions.pyi (2ms)
2024-07-16 11:31:59.674 [info] (14842) [BG(1)]   checking: file:///Users/wannes/Desktop/repo/main/src/main.py (190ms)
2024-07-16 11:31:59.674 [info] (14842) [BG(1)] analyzing: file:///Users/wannes/Desktop/repo/main/src/main.py (379ms)
2024-07-16 11:31:59.678 [info] (14842) [BG(1)] SemanticTokens range 0:0 - 3:0 at file:///Users/wannes/Desktop/repo/main/src/main.py (2ms)
2024-07-16 11:31:59.679 [info] (14842) [BG(1)] SemanticTokens full at file:///Users/wannes/Desktop/repo/main/src/main.py (0ms)
2024-07-16 11:31:59.684 [info] (14842) [BG(1)] indexing: file:///Users/wannes/Desktop/repo/main/src/main.py [found 1] (0ms)
2024-07-16 11:31:59.684 [info] (14842) Indexing Done: file:///Users/wannes/Desktop/repo/main/src/main.py
2024-07-16 11:31:59.769 [info] (14842) [BG(1)] indexing: file:///Users/wannes/Desktop/repo/main/src/typing_extensions.py ...
2024-07-16 11:31:59.769 [info] (14842) [BG(1)]   parsing: file:///Users/wannes/Desktop/repo/main/src/typing_extensions.py [fs read 4ms] (87ms)
2024-07-16 11:31:59.802 [info] (14842) [BG(1)]   binding: file:///Users/wannes/Desktop/repo/main/src/typing_extensions.py (34ms)
2024-07-16 11:31:59.817 [info] (14842) [BG(1)] indexing: file:///Users/wannes/Desktop/repo/main/src/typing_extensions.py [found 187] (137ms)
2024-07-16 11:31:59.818 [info] (14842) Indexing Done: file:///Users/wannes/Desktop/repo/main/src/typing_extensions.py
2024-07-16 11:31:59.864 [info] (14842) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:31:59.886 [info] (14842) [IDX(2)] scan packages file:///Users/wannes/Desktop/repo (444ms)
2024-07-16 11:31:59.886 [info] [Info  - 11:31:59] (14842) scanned(2) 18 files over 1 exec env
2024-07-16 11:32:00.041 [info] (14842) [IDX(2)] index packages file:///Users/wannes/Desktop/repo ...
2024-07-16 11:32:00.042 [info] (14842) [IDX(2)]   index execution environment file:///Users/wannes/Desktop/repo ...
2024-07-16 11:32:00.043 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/__phello__/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.043 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.043 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/idlelib/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.044 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib2to3/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.044 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pydoc_data/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.044 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/test/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.044 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/turtledemo/__init__.py [skipped: no '__all__' defined] (1ms)
2024-07-16 11:32:00.044 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.044 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/wsgiref/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.045 [info] (14842) [IDX(2)]     indexing: file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/xmlrpc/__init__.py [skipped: no '__all__' defined] (0ms)
2024-07-16 11:32:00.046 [info] (14842) [IDX(2)]   index execution environment file:///Users/wannes/Desktop/repo [found 855 in 8 files] (5ms)
2024-07-16 11:32:00.046 [info] (14842) [IDX(2)] index packages file:///Users/wannes/Desktop/repo [found 855 in 1 exec envs] (11ms)
2024-07-16 11:32:00.047 [info] [Info  - 11:32:00] (14842) indexed(2) 8 files over 1 exec env
2024-07-16 11:32:00.063 [info] [Info  - 11:32:00] (14842) Indexing finished(2).
2024-07-16 11:32:00.270 [info] (14842) [BG(1)] SemanticTokens delta previousResultId:1721122319678 at file:///Users/wannes/Desktop/repo/main/src/main.py (1ms)
2024-07-16 11:32:01.986 [info] [Info  - 11:32:01] (14842) Starting service instance "<default>"
2024-07-16 11:32:01.986 [info] (14842) WorkspaceFactory 0 add <default>:mutable
2024-07-16 11:32:01.992 [info] (14842) Server settings returned for workspace: undefined: {
  "autoSearchPaths": true,
  "disableLanguageServices": false,
  "openFilesOnly": true,
  "useLibraryCodeForTypes": true,
  "watchForSourceChanges": true,
  "watchForLibraryChanges": true,
  "watchForConfigChanges": true,
  "typeCheckingMode": "strict",
  "diagnosticSeverityOverrides": {
    "reportShadowedImports": "warning"
  },
  "logLevel": "log",
  "autoImportCompletions": true,
  "indexing": false,
  "completeFunctionParens": false,
  "enableExtractCodeAction": true,
  "indexOptions": {
    "packageDepths": [
      [
        "sklearn",
        2,
        false
      ],
      [
        "matplotlib",
        2,
        false
      ],
      [
        "scipy",
        2,
        false
      ],
      [
        "django",
        2,
        false
      ],
      [
        "flask",
        2,
        false
      ],
      [
        "fastapi",
        2,
        false
      ]
    ],
    "userFileIndexingLimit": 2000
  },
  "variableInlayTypeHints": false,
  "callArgumentNameInlayHints": "off",
  "functionReturnInlayTypeHints": false,
  "pytestParametersInlayTypeHints": false,
  "importFormat": "absolute",
  "includeFileSpecs": [],
  "excludeFileSpecs": [],
  "ignoreFileSpecs": [],
  "formatOnType": true,
  "taskListTokens": [],
  "enablePytestSupport": true,
  "gotoDefinitionInStringLiteral": true,
  "remapDiagnostics": false,
  "intelliCodeEnabled": true,
  "pythonPath": {
    "_key": "/usr/local/bin/python3",
    "_filePath": "/usr/local/bin/python3",
    "_query": "",
    "_fragment": "",
    "_originalString": "file:///usr/local/bin/python3",
    "_isCaseSensitive": false
  },
  "pythonEnvironmentName": "3.12.4 (global)",
  "fixAll": [],
  "extraCommitChars": false,
  "autoFormatStrings": false,
  "autoIndent": true,
  "supportRestructuredText": false,
  "collectModuleInfo": false,
  "nodeExecutable": "",
  "notebookRunStartupCommands": "",
  "editorIndentConfig": {
    "defaultTabSequence": "    ",
    "tabSize": 4
  }
}
2024-07-16 11:32:01.999 [info] (14842) No pyproject.toml file found.
2024-07-16 11:32:02.000 [info] [Info  - 11:32:02] (14842) Setting pythonPath for service "<default>": "/usr/local/bin/python3"
2024-07-16 11:32:02.000 [info] [Info  - 11:32:02] (14842) Setting environmentName for service "<default>": "3.12.4 (global)"
2024-07-16 11:32:02.000 [info] [Info  - 11:32:02] (14842) No include entries specified; assuming /<default workspace root>
2024-07-16 11:32:02.001 [info] [Info  - 11:32:02] (14842) Auto-excluding **/node_modules
2024-07-16 11:32:02.001 [info] [Info  - 11:32:02] (14842) Auto-excluding **/__pycache__
2024-07-16 11:32:02.001 [info] [Info  - 11:32:02] (14842) Auto-excluding **/.*
2024-07-16 11:32:02.049 [info] [Info  - 11:32:02] (14842) Assuming Python version 3.12.4.final.0
2024-07-16 11:32:02.049 [info] (14842) Assuming Python platform Darwin
2024-07-16 11:32:02.116 [info] [Info  - 11:32:02] (14842) Search paths for file:///%3Cdefault%20workspace%20root%3E
2024-07-16 11:32:02.117 [info] [Info  - 11:32:02] (14842)   /Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib
2024-07-16 11:32:02.118 [info] [Info  - 11:32:02] (14842)   /<default workspace root>
2024-07-16 11:32:02.118 [info] [Info  - 11:32:02] (14842)   /<default workspace root>/typings
2024-07-16 11:32:02.119 [info] [Info  - 11:32:02] (14842)   /Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stubs/...
2024-07-16 11:32:02.119 [info] [Info  - 11:32:02] (14842)   /Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/bundled/stubs
2024-07-16 11:32:02.120 [info] [Info  - 11:32:02] (14842)   /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12
2024-07-16 11:32:02.120 [info] [Info  - 11:32:02] (14842)   /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload
2024-07-16 11:32:02.121 [info] [Info  - 11:32:02] (14842)   /usr/local/lib/python3.12/site-packages
2024-07-16 11:32:02.121 [info] [Info  - 11:32:02] (14842) Adding fs watcher for library directories:
 file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12
file:///usr/local/Cellar/python%403.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload
file:///usr/local/lib/python3.12/site-packages
2024-07-16 11:32:02.122 [info] [Info  - 11:32:02] (14842) Adding fs watcher for directories:
 file:///%3Cdefault%20workspace%20root%3E
2024-07-16 11:32:02.122 [info] (14842) Searching for source files
2024-07-16 11:32:02.123 [info] [Error - 11:32:02] (14842) File or directory "/<default workspace root>" does not exist.
2024-07-16 11:32:02.124 [info] [Info  - 11:32:02] (14842) No source files found.
2024-07-16 11:32:02.127 [info] (14842) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:32:02.128 [info] (14842) IntelliCode model /Users/wannes/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.3.1/dist/bundledModels/python_intellisense-members-lstm-pylance
2024-07-16 11:32:02.307 [info] (14842) pytest configurations: {"message":"script","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:32:02.485 [info] [Info  - 11:32:02] (14842) Background analysis(3) root directory: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-16 11:32:02.488 [info] [Info  - 11:32:02] (14842) Background analysis(3) started
2024-07-16 11:32:02.572 [info] (14842) pytest configurations: {"message":"request cancelled","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:32:02.572 [info] (14842) pytest configurations: {"message":"spawn /usr/local/bin/python3 ENOENT","classes":["Test"],"files":["test_*.py","*_test.py"],"functions":["test"]}
2024-07-16 11:32:02.867 [info] (14842) Loading ONNX runtime...
2024-07-16 11:32:02.868 [info] (14842) Loaded ONNX runtime. Creating IntelliCode session...
2024-07-16 11:32:02.980 [info] 2024-07-16 11:32:02.978806 [I:onnxruntime:, inference_session.cc:328 operator()] Flush-to-zero and denormal-as-zero are off

2024-07-16 11:32:02.980 [info] 2024-07-16 11:32:02.980226 [I:onnxruntime:, inference_session.cc:336 ConstructorCommon] Creating and using per session threadpools since use_per_session_threads_ is true
2024-07-16 11:32:02.980328 [I:onnxruntime:, inference_session.cc:354 ConstructorCommon] Dynamic block base set to 0

2024-07-16 11:32:03.024 [info] 2024-07-16 11:32:03.024599 [I:onnxruntime:, inference_session.cc:1400 Initialize] Initializing session.

2024-07-16 11:32:03.025 [info] 2024-07-16 11:32:03.024721 [I:onnxruntime:, inference_session.cc:1437 Initialize] Adding default CPU execution provider.

2024-07-16 11:32:03.062 [info] 2024-07-16 11:32:03.062506 [I:onnxruntime:, graph.cc:3556 CleanUnusedInitializersAndNodeArgs] Removing initializer 'pred_embedding_to_output_layer/einsum_1/mul/x:0'. It is no longer used by any node.

2024-07-16 11:32:03.070 [info] 2024-07-16 11:32:03.070156 [I:onnxruntime:, graph.cc:3619 CleanUnusedInitializersAndNodeArgs] Removing NodeArg 'rnn/transpose'. It is no longer used by any node.

2024-07-16 11:32:03.070 [info] 2024-07-16 11:32:03.070304 [I:onnxruntime:, graph.cc:3619 CleanUnusedInitializersAndNodeArgs] Removing NodeArg 'Gather_out0'. It is no longer used by any node.
2024-07-16 11:32:03.070380 [I:onnxruntime:, graph.cc:3619 CleanUnusedInitializersAndNodeArgs] Removing NodeArg 'Transpose_out0'. It is no longer used by any node.

2024-07-16 11:32:03.101 [info] 2024-07-16 11:32:03.100922 [V:onnxruntime:, session_state.cc:1142 VerifyEachNodeIsAssignedToAnEp] Node placements

2024-07-16 11:32:03.101 [info] 2024-07-16 11:32:03.101236 [V:onnxruntime:, session_state.cc:1145 VerifyEachNodeIsAssignedToAnEp]  All nodes placed on [CPUExecutionProvider]. Number of nodes: 56

2024-07-16 11:32:03.108 [info] 2024-07-16 11:32:03.107755 [V:onnxruntime:, session_state.cc:126 CreateGraphInfo] SaveMLValueNameIndexMapping

2024-07-16 11:32:03.108 [info] 2024-07-16 11:32:03.108015 [V:onnxruntime:, session_state.cc:172 CreateGraphInfo] Done saving OrtValue mappings.

2024-07-16 11:32:03.108 [info] 2024-07-16 11:32:03.108462 [I:onnxruntime:, allocation_planner.cc:2401 CreateGraphPartitioner] Use DeviceBasedPartition as default

2024-07-16 11:32:03.111 [info] 2024-07-16 11:32:03.111442 [I:onnxruntime:, session_state_utils.cc:201 SaveInitializedTensors] Saving initialized tensors.

2024-07-16 11:32:03.136 [info] 2024-07-16 11:32:03.136124 [I:onnxruntime:, session_state_utils.cc:345 SaveInitializedTensors] Done saving initialized tensors

2024-07-16 11:32:03.141 [info] 2024-07-16 11:32:03.141142 [I:onnxruntime:, inference_session.cc:1774 Initialize] Session successfully initialized.

2024-07-16 11:32:03.142 [info] (14842) Created IntelliCode session.
2024-07-16 11:32:03.142 [info] (14842) Initialize deeplearning succeeded
2024-07-16 11:32:05.936 [info] (14842) [FG] parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing.pyi [fs read 1ms] (28ms)
2024-07-16 11:32:05.949 [info] (14842) [FG] binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing.pyi (12ms)
2024-07-16 11:32:05.969 [info] (14842) [FG] parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/types.pyi [fs read 0ms] (8ms)
2024-07-16 11:32:05.977 [info] (14842) [FG] binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/types.pyi (8ms)
2024-07-16 11:32:05.989 [info] (14842) [FG] parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (6ms)
2024-07-16 11:32:05.993 [info] (14842) [FG] binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (4ms)
2024-07-16 11:32:06.000 [info] (14842) [FG] parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/abc.pyi [fs read 0ms] (1ms)
2024-07-16 11:32:06.001 [info] (14842) [FG] binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/abc.pyi (1ms)
2024-07-16 11:32:06.009 [info] (14842) [FG] parsing: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 0ms] (6ms)
2024-07-16 11:32:06.013 [info] (14842) [FG] binding: file:///Users/wannes/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist/typeshed-fallback/stdlib/typing_extensions.pyi (4ms)
debonte commented 1 month ago

@erictraut is the best person to answer this, but I believe it is by design given our import resolution order described here: https://microsoft.github.io/pyright/#/import-resolution?id=resolution-order.

Here are some ways you could fix this:

  1. Use a relative import -- from .typing_extensions import Literal
  2. Move typing_extensions.py into your virtual environment.
  3. Move typing_extensions.py to your workspace root, your stubPath, or a location in your extraPaths, although that will result in a reportShadowedImports diagnostic.
nineteendo commented 1 month ago

I believe it is by design given our import resolution order

Note that it doesn't complain if I rename typing_extensions.py to typing_extensions_1.py.

For an absolute import, if all of the above attempts fail, attempt to import a module from the same directory as the importing file and parent directories that are also children of the root workspace. This accommodates cases where it is assumed that a Python script will be executed from one of these subdirectories rather than from the root directory.

Somehow this step is being skipped for typing_extensions.

Use a relative import

That won't work, as the libraries can be optionally installed.

Move typing_extensions.py into your virtual environment.

I don't think that will make a difference, I'm getting this error if typing_extensions isn't globally installed. Which is the whole point of this, you can test the code immediately after downloading from GitHub without needing to set up a virtual environment or install dependencies.

Move typing_extensions.py to your workspace root, your stubPath, or a location in your extraPaths, although that will result in a reportShadowedImports diagnostic.

It's very convenient to have the different branches of the repository as subfolders (work trees) of the workspace root. And typing_extensions.py must be in <branch>/src/. Because these paths are arbitrary, I can't specify them.

Shouldn't it only report shadowed imports if it can't find the imported symbol, but it's present in the shadowed module?

nineteendo commented 1 month ago

I don't want to write from typing_extensions import ... # type: ignore in every file.

debonte commented 1 month ago

Note that it doesn't complain if I rename typing_extensions.py to typing_extensions_1.py.

Yes, that's because when you import typing_extensions it's resolving to the typing_extensions in typeshed. When you give it a unique name we don't find a match in typeshed and find the unique name in step 6 of the import resolution order -- https://microsoft.github.io/pyright/#/import-resolution?id=resolution-order

Somehow this step is being skipped for typing_extensions.

It's not skipped really. We never get there. We found typing_extensions in typeshed in step 5 which takes priority over step 6.

Move typing_extensions.py into your virtual environment.

I don't think that will make a difference, I'm getting this error if typing_extensions isn't globally installed.

Hmmm, it worked for me and I don't have typing_extensions installed globally. The point of this would be that our import resolver would find it in your venv before looking in typeshed.

Shouldn't it only report shadowed imports if it can't find the imported symbol, but it's present in the shadowed module?

The shadowed import diagnostic is not about a symbol, but rather a module -- in these scenarios it's warning that your local typing_extensions is resolving instead of the pyi from stdlib.

Use a relative import

That won't work, as the libraries can be optionally installed.

What happens when it's not installed? If you don't have typing_extensions.py in the local directory, do you want to fall back to some other copy? The one in your venv?

nineteendo commented 1 month ago

We never get there.

If it can't resolve the module, it should move on the step 6:

if all of the above attempts fail, attempt to import a module from the same directory


Hmmm, it worked for me

root/venv/src/typing_extensions.py is still not found.

What happens when it's not installed?

It will be better to explain with an example: https://github.com/nineteendo/pyvz2/tree/alpha

pyvz2-alpha
+-src
  |-jsonyx
  |-__main__.py
  +-typing_extensions.py

If you download this repository you can run the jsonyx tool directly with python src json. If you want to use the C accelerators or use the module in your own scripts, you can install it with pip install src/.

Here's the thing: if I don't include typing_extensions.py in src/, you HAVE to use a venv or install it globally. You won't be able to run it directly.

So, this means that I freeze typing_extensions to a specific version in my project, but not when used elsewhere after installation.

debonte commented 1 month ago

If it can't resolve the module, it should move on the step 6:

Yes, but it did resolve the module. It found it in Pylance's bundled copy of typeshed.

root/venv/src/typing_extensions.py is still not found.

It needs to be under site-packages.

I'll try your repo later today.

erictraut commented 1 month ago

The typing_extensions module is a special case because it's included in the typeshed "stdlib" stubs but is not actually part of stdlib.

I'm not that familiar with the code in pyright that tracks "shadowed" modules (i.e. ".py" files that correspond to ".pyi" files). This functionality was added by the pylance team (along with the reportMissingModuleSource check) and isn't used by the core type checking functionality. Perhaps the shadowing logic is making incorrect assumptions about "typing_extensions" based on the fact that it's part of typeshed's stdlib stubs?

nineteendo commented 1 month ago

Yeah, I think that's exactly what's happening. That also explains why it gives this error if I open the worktree directly:

"/Users/wannes/Library/CloudStorage/OneDrive-Personal/Personal/GitHub/pyvz2/alpha/src/typing_extensions.py" is overriding the STDLIB module "typing_extensions"

So, that error message is not even correct.

debonte commented 1 month ago

Changing the shadowed import diagnostic behavior isn't going to change how the import is resolved though. Are you saying that one of the alternatives I listed above would work for you, except for the diagnostic? If that's the case, while we consider whether to change the diagnostic's behavior with typing_extensions you could disable the diagnostic?

nineteendo commented 1 month ago

It's fine to resolve to the stub file, but isn't there a second kind of resolving going on:

Import "typing_extensions" could not be resolved from source

Right now I'm suppressing the error with type: ignore.

debonte commented 1 month ago

It's fine to resolve to the stub file, but isn't there a second kind of resolving going on:

Yes, we do a separate resolution to look for the source file, and in this case we don't do step 6 in the resolution order that we were discussing above.

I agree that this is a bug, but it's not clear to me that it impacts a large number of users. Wanting to match a library/built-in stub with a user source file seems unusual. Without feedback from more users indicating that this is problematic, it's unlikely that we will prioritize fixing it.

Therefore, I'm inclined to treat this as an enhancement and move it to discussions to see if other users up-vote it.

Right now I'm suppressing the error with type: ignore.

Note that you can suppress the reportMissingModuleSource diagnostic globally in a pyrightconfig.json file (see sample here) or your VS Code settings (python.analysis.diagnosticSeverityOverrides).