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

Type of "globals" is unknown when module named as globals #2793

Closed
NateScarlet opened this issue May 10, 2022 · 3 comments
Closed

Type of "globals" is unknown when module named as globals #2793

NateScarlet opened this issue May 10, 2022 · 3 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@NateScarlet
Copy link

Environment data

  • Language Server version: v2022.4.3
  • OS and version: Windows10 21H2
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32

Expected behavior

no error been reported

Actual behavior

pylance says globals is unknown type,

图片

while command line pyright(1.1.245) reports no error

Logs

[Info  - 00:48:39] (12732) Pylance language server 2022.4.3 (pyright 88f2a424) starting
[Info  - 00:48:39] (12732) Server root directory: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist
[Info  - 00:48:39] (12732) No configuration file found.
[Info  - 00:48:39] (12732) No pyproject.toml file found.
[Info  - 00:48:39] (12732) Setting pythonPath for service "pylance-repro": "{HOME}\src\github.com\NateScarlet\pylance-repro\py"
[Warn  - 00:48:39] (12732) stubPath {HOME}\src\github.com\NateScarlet\pylance-repro\typings is not a valid directory.
[Info  - 00:48:39] (12732) Unable to get Python version from interpreter
[Info  - 00:48:39] (12732) Assuming Python platform Windows
[Info  - 00:48:39] (12732) Search paths for {HOME}\src\github.com\NateScarlet\pylance-repro
[Info  - 00:48:39] (12732)   {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib
[Info  - 00:48:39] (12732)   {HOME}\src\github.com\NateScarlet\pylance-repro
[Info  - 00:48:39] (12732)   {HOME}\src\github.com\NateScarlet\pylance-repro\typings
[Info  - 00:48:39] (12732)   {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\...
[Info  - 00:48:39] (12732)   {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs
[Info  - 00:48:39] (12732) Adding fs watcher for directories:
 {HOME}\src\github.com\NateScarlet\pylance-repro
[Info  - 00:48:39] (12732) Searching for source files
[Info  - 00:48:39] (12732) Found 3 source files
(12732) [FG] parsing: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (31ms)
(12732) [FG] parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 5ms] (278ms)
(12732) [FG] binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\builtins.pyi (113ms)
(12732) [FG] binding: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (1ms)
[Info  - 00:48:40] (12732) Background analysis(1) root directory: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist
[Info  - 00:48:40] (12732) Background analysis(1) started
(12732) Background analysis message: setConfigOptions
(12732) Background analysis message: setImportResolver
(12732) Background analysis message: ensurePartialStubPackages
(12732) IntelliCode model {HOME}\.vscode\extensions\visualstudioexptteam.vscodeintellicode-1.2.20\cache\E61945A9A512ED5E1A3EE3F1A2365B88F8FE_E4E9EADA96734F01970E616FAB2FAC19
(12732) Background analysis message: setTrackedFiles
(12732) Background analysis message: markAllFilesDirty
(12732) Background analysis message: setFileOpened
(12732) Background analysis message: getSemanticTokens full
(12732) [BG(1)] getSemanticTokens full at {HOME}\src\github.com\NateScarlet\pylance-repro\module.py ...
(12732) [BG(1)]   parsing: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (26ms)
[Info  - 00:48:40] (12732) Indexer background runner(2) root directory: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist (index)
[Info  - 00:48:40] (12732) Indexing(2) started
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 7ms] (219ms)
(12732) [IDX(2)] index libraries {HOME}\src\github.com\NateScarlet\pylance-repro ...
(12732) [IDX(2)]   read stdlib indices (111ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\builtins.pyi (112ms)
(12732) [BG(1)]   binding: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (0ms)
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\typing_extensions.pyi [fs read 6ms] (29ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\typing_extensions.pyi (8ms)
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\typing.pyi [fs read 1ms] (80ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\typing.pyi (31ms)
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\_typeshed\__init__.pyi [fs read 1ms] (26ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\_typeshed\__init__.pyi (4ms)
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\types.pyi [fs read 1ms] (19ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\types.pyi (14ms)
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\abc.pyi [fs read 1ms] (4ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\abc.pyi (0ms)
(12732) [BG(1)]   parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\__future__.pyi [fs read 1ms] (2ms)
(12732) [BG(1)]   binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\__future__.pyi (1ms)
(12732) [BG(1)]   parsing: {HOME}\src\github.com\NateScarlet\pylance-repro\globals.py [fs read 0ms] (1ms)
(12732) [BG(1)]   binding: {HOME}\src\github.com\NateScarlet\pylance-repro\globals.py (2ms)
(12732) [BG(1)] getSemanticTokens full at {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (700ms)
(12732) Background analysis message: analyze
(12732) [BG(1)] analyzing: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py ...
(12732) [BG(1)]   checking: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (15ms)
(12732) [BG(1)] analyzing: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (15ms)
(12732) Background analysis message: getSemanticTokens range
(12732) [BG(1)] getSemanticTokens range 0:0 - 9:0 at {HOME}\src\github.com\NateScarlet\pylance-repro\module.py (1ms)
(12732) Background analysis message: resumeAnalysis
(12732) [BG(1)] parsing: {HOME}\src\github.com\NateScarlet\pylance-repro\__init__.py [fs read 1ms] (1ms)
(12732) [BG(1)] binding: {HOME}\src\github.com\NateScarlet\pylance-repro\__init__.py (0ms)
(12732) [BG(1)] indexing: {HOME}\src\github.com\NateScarlet\pylance-repro\__init__.py [found 0] (1ms)
(12732) Indexing Done: {HOME}\src\github.com\NateScarlet\pylance-repro\__init__.py
(12732) [BG(1)] indexing: {HOME}\src\github.com\NateScarlet\pylance-repro\globals.py [found 1] (0ms)
(12732) Indexing Done: {HOME}\src\github.com\NateScarlet\pylance-repro\globals.py
(12732) [BG(1)] indexing: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py [found 0] (0ms)
(12732) Indexing Done: {HOME}\src\github.com\NateScarlet\pylance-repro\module.py
(12732) [IDX(2)]   scan packages [found 2 modules over 1 exec env] (669ms)
(12732) [IDX(2)]   index execution environment {HOME}\src\github.com\NateScarlet\pylance-repro ...
(12732) [IDX(2)]     parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\jmespath\jmespath\__init__.pyi [fs read 0ms] (269ms)
(12732) [IDX(2)]     parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 11ms] (158ms)
(12732) [IDX(2)]     binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stdlib\builtins.pyi (20ms)
(12732) [IDX(2)]     binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\jmespath\jmespath\__init__.pyi (1ms)
(12732) [IDX(2)]     indexing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\jmespath\jmespath\__init__.pyi ...
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\jmespath\__init__.pyi [fs read 2ms] (5ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\jmespath\__init__.pyi (0ms)
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\jmespath\visitor.pyi [fs read 1ms] (2ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\jmespath\visitor.pyi (0ms)
(12732) [IDX(2)]     indexing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\jmespath\jmespath\__init__.pyi [found 3] (15ms)
(12732) [IDX(2)]     parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\__init__.pyi [fs read 0ms] (6ms)
(12732) [IDX(2)]     binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\__init__.pyi (1ms)
(12732) [IDX(2)]     indexing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\__init__.pyi ...
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\compat\numbers.pyi [fs read 1ms] (1ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\compat\numbers.pyi (1ms)
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\reader\excel.pyi [fs read 0ms] (4ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\reader\excel.pyi (0ms)
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\workbook\__init__.pyi [fs read 0ms] (0ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\workbook\__init__.pyi (0ms)
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\workbook\workbook.pyi [fs read 1ms] (7ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\workbook\workbook.pyi (0ms)
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\xml\__init__.pyi [fs read 1ms] (1ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\bundled\stubs\openpyxl\xml\__init__.pyi (1ms)
(12732) [IDX(2)]       parsing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\_constants.pyi [fs read 0ms] (1ms)
(12732) [IDX(2)]       binding: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\_constants.pyi (0ms)
(12732) [IDX(2)]     indexing: {HOME}\.vscode\extensions\ms-python.vscode-pylance-2022.4.3\dist\typeshed-fallback\stubs\openpyxl\openpyxl\__init__.pyi [found 9] (20ms)
(12732) [IDX(2)]   index execution environment {HOME}\src\github.com\NateScarlet\pylance-repro [found 9046 in 424 files] (505ms)
(12732) [IDX(2)] index libraries {HOME}\src\github.com\NateScarlet\pylance-repro [found 9046 in 1 exec envs] (1288ms)
[Info  - 00:48:42] (12732) Indexer done(2). indexed 424 files
(12732) Loading ONNX runtime...
(12732) Loaded ONNX runtime. Creating IntelliCode session...
(12732) Created IntelliCode session.
(12732) Initialize deeplearning succeeded
(12732) [FG] parsing: {HOME}\src\github.com\NateScarlet\pylance-repro\globals.py [fs read 3ms] (4ms)
(12732) [FG] binding: {HOME}\src\github.com\NateScarlet\pylance-repro\globals.py (0ms)
(12732) Background analysis message: getDiagnosticsForRange
(12732) Background analysis message: getDiagnosticsForRange

Code Snippet / Additional information

pylance-repro.zip

@judej judej added the needs investigation Could be an issue - needs investigation label May 10, 2022
@github-actions github-actions bot removed the triage label May 10, 2022
@erictraut
Copy link
Contributor

Thanks for the bug report and the zip file. I'm able to repro the problem as reported, but it's intermittent. If I make a modification to the file, the problem goes away. This provides us a good clue. I'll continue to investigate.

@erictraut
Copy link
Contributor

I found and fixed the issue. This will be addressed in the next release.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels May 10, 2022
@bschnurr
Copy link
Member

This issue has been fixed in version 2022.5.1, which we've just released. You can find the changelog here: CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants