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

Internal type checking error when method name matches the name of the return type #181

Closed
la-mar opened this issue Jul 28, 2020 · 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

@la-mar
Copy link

la-mar commented Jul 28, 2020

Naming a method using the name of a builtin type and specifying the same builtin type as the return type appears to be the cause of the problem.

Environment data

  • Language Server version: 2020.7.3
  • OS and version: macOS Catalina 10.15.5
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.1

Expected behaviour

No Error

Actual behaviour

Problem: "An internal error occurred while performing type checking". Please see logs below.

Logs

[Info  - 6:51:37 AM] Pylance language server 2020.7.3 (pyright 5004efe5) starting
[Info  - 6:51:37 AM] Server root directory: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server
[Info  - 6:51:37 AM] Loading configuration file at /Users/friedrichb/repo/loco-api/pyrightconfig.json
[Info  - 6:51:37 AM] Assuming Python version 3.8
[Info  - 6:51:37 AM] Assuming Python platform Darwin
[Info  - 6:51:37 AM] No include entries specified; assuming /Users/friedrichb/repo/loco-api
[Info  - 6:51:37 AM] Auto-excluding **/node_modules
[Info  - 6:51:37 AM] Auto-excluding **/__pycache__
[Info  - 6:51:37 AM] Auto-excluding .git
[Info  - 6:51:38 AM] Setting pythonPath for service "loco-api": "/Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/bin/python"
[Error - 6:51:38 AM] stubPath /Users/friedrichb/repo/loco-api/typings is not a valid directory.
[Info  - 6:51:38 AM] Searching for source files
[Info  - 6:51:38 AM] Found 91 source files
[Info  - 6:51:38 AM] Background analysis root directory: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server
[Info  - 6:51:38 AM] Background analysis started
[FG] parsing: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py (45ms)
[FG] parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/builtins.pyi (90ms)
[FG] binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/builtins.pyi (45ms)
[FG] binding: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py (5ms)
[FG] parsing: /Users/friedrichb/repo/loco-api/src/loco/db/__init__.py (14ms)
[FG] binding: /Users/friedrichb/repo/loco-api/src/loco/db/__init__.py (1ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/__init__.py (4ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/__init__.py ...
[FG]   parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/exceptions.py (0ms)
[FG]   binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/exceptions.py (0ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/__init__.py (2ms)
[FG] parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/logging/__init__.pyi (22ms)
[FG] binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/logging/__init__.pyi (5ms)
[FG] parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/typing.pyi (26ms)
[FG] binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/typing.pyi (21ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/api.py (20ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/api.py (3ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/__init__.py (33ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/__init__.py (2ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/schema.py (8ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/schema.py (0ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/schema.py (91ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/schema.py (23ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/base.py (13ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/base.py (6ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/__init__.py (8ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/__init__.py (2ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py (11ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py (2ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/compat.py (21ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/compat.py (5ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/inspection.py (1ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/inspection.py (1ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/declarative.py (6ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/declarative.py (2ms)
[FG] parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/crud.py (8ms)
[FG] binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/crud.py (4ms)
[FG] parsing: /Users/friedrichb/repo/loco-api/src/loco/db/mixins.py (8ms)
[FG] binding: /Users/friedrichb/repo/loco-api/src/loco/db/mixins.py (2ms)
[FG] parsing: /Users/friedrichb/repo/loco-api/src/loco/util/deco.py (2ms)
[FG] binding: /Users/friedrichb/repo/loco-api/src/loco/util/deco.py (0ms)
[Error - 6:51:38 AM] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: Debug Failure. False expression.
  Code: -32603 
IntelliCode model /Users/friedrichb/.vscode/extensions/visualstudioexptteam.vscodeintellicode-1.2.9/cache/15708AE89896CA5DF1690433B7A8D93D28B7_215F8B4FAB1F4663ABD624559FD205B9
Loading ONNX runtime...
Loaded ONNX runtime. Creating IntelliCode session...
2020-07-28 05:51:39.170689 [I:onnxruntime:, inference_session.cc:174 ConstructorCommon] Creating and using per session threadpools since use_per_session_threads_ is true
2020-07-28 05:51:39.171132 [W:onnxruntime:, graph.cc:814 Graph] Initializer embeddings_matrix:0_quantized appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-07-28 05:51:39.171148 [W:onnxruntime:, graph.cc:814 Graph] Initializer embeddings_matrix:0_scale appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-07-28 05:51:39.171159 [W:onnxruntime:, graph.cc:814 Graph] Initializer embeddings_matrix:0_zero_point appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-07-28 05:51:39.171169 [W:onnxruntime:, graph.cc:814 Graph] Initializer fixed_quantization_range_uint8 appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-07-28 05:51:39.171177 [W:onnxruntime:, graph.cc:814 Graph] Initializer fixed_zero appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-07-28 05:51:39.172696 [I:onnxruntime:, inference_session.cc:830 Initialize] Initializing session.
2020-07-28 05:51:39.172714 [I:onnxruntime:, inference_session.cc:848 Initialize] Adding default CPU execution provider.
2020-07-28 05:51:39.174647 [I:onnxruntime:, reshape_fusion.cc:37 ApplyImpl] Total fused reshape node count: 0
2020-07-28 05:51:39.175161 [I:onnxruntime:, reshape_fusion.cc:37 ApplyImpl] Total fused reshape node count: 0
2020-07-28 05:51:39.176447 [V:onnxruntime:, inference_session.cc:671 TransformGraph] Node placements
2020-07-28 05:51:39.176457 [V:onnxruntime:, inference_session.cc:673 TransformGraph] All nodes have been placed on [CPUExecutionProvider].
2020-07-28 05:51:39.176485 [I:onnxruntime:, session_state.cc:25 SetGraph] SaveMLValueNameIndexMapping
2020-07-28 05:51:39.176548 [I:onnxruntime:, session_state.cc:70 SetGraph] Done saving OrtValue mappings.
2020-07-28 05:51:39.177418 [I:onnxruntime:, session_state_initializer.cc:178 SaveInitializedTensors] Saving initialized tensors.
2020-07-28 05:51:39.199245 [I:onnxruntime:, session_state_initializer.cc:223 SaveInitializedTensors] Done saving initialized tensors
2020-07-28 05:51:39.201658 [I:onnxruntime:, inference_session.cc:919 Initialize] Session successfully initialized.
Created IntelliCode session.
[BG] analyzing: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py ...
[BG]   parsing: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py (88ms)
[BG]   parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/builtins.pyi (107ms)
[BG]   binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/builtins.pyi (45ms)
[BG]   binding: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py (4ms)
[BG]   checking: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py ...
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/typing.pyi (28ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/typing.pyi (9ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/__future__.pyi (2ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/__future__.pyi (0ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/dialects/asyncpg.py (26ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/dialects/asyncpg.py (6ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/__init__.py (7ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/__init__.py (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/json.py (6ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/json.py (2ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/types.py (5ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/types.py (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/__init__.py (6ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/__init__.py (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/operators.py (27ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/operators.py (7ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/sqltypes.py (50ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/sqltypes.py (15ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/datetime.pyi (8ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/datetime.pyi (4ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/type_api.py (12ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/type_api.py (4ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py (5ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py (4ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/__init__.py (9ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/__init__.py (2ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/compat.py (28ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/compat.py (4ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/__init__.py (22ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/__init__.py (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/schema.py (4ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/schema.py (0ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/schema.py (44ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/schema.py (21ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/base.py (9ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/base.py (3ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/inspection.py (1ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/inspection.py (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/elements.py (32ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/elements.py (16ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/re.pyi (3ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/re.pyi (0ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/abc.pyi (0ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/abc.pyi (0ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/enum.pyi (1ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/enum.pyi (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/base.py (33ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/base.py (19ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/dml.py (2ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/dml.py (0ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/dml.py (4ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/dml.py (1ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/selectable.py (28ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/sql/selectable.py (11ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/_collections.py (7ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/_collections.py (4ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/util/__init__.py (0ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/util/__init__.py (0ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/util/jsontools.py (4ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/util/jsontools.py (1ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/db/__init__.py (2ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/db/__init__.py (0ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/__init__.py (6ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/__init__.py ...
[BG]       parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/exceptions.py (1ms)
[BG]       binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/exceptions.py (0ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/__init__.py (1ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/logging/__init__.pyi (7ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/2and3/logging/__init__.pyi (3ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/api.py (8ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/api.py (4ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/db/mixins.py (9ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/db/mixins.py (1ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/util/deco.py (1ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/util/deco.py (0ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/util/dt.py (2ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/util/dt.py (0ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/declarative.py (4ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/declarative.py (3ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/crud.py (7ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/gino/crud.py (2ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/exc.py (4ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/exc.py (2ms)
[BG]     parsing: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py (18ms)
[BG]     binding: /Users/friedrichb/Library/Caches/pypoetry/virtualenvs/loco-api-Q1D5Zc5r-py3.8/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py (13ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/functools.pyi (3ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/functools.pyi (1ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/types.pyi (4ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/types.pyi (3ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/inspect.pyi (3ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/inspect.pyi (3ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/collections/__init__.pyi (5ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/collections/__init__.pyi (4ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/sys.pyi (2ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/sys.pyi (2ms)
[BG]     parsing: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/itertools.pyi (2ms)
[BG]     binding: /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/typeshed-fallback/stdlib/3/itertools.pyi (2ms)
[BG]     parsing: /Users/friedrichb/repo/loco-api/src/loco/util/iterables.py (0ms)
[BG]     binding: /Users/friedrichb/repo/loco-api/src/loco/util/iterables.py (1ms)
[Error - 6:51:39 AM] An internal error occurred while while performing type checking for /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py: Error: Debug Failure. False expression.
    at it (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:273786)
    at /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:302286
    at /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:302238
    at zt (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:302278)
    at Ut (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:301950)
    at tn (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:319604)
    at nn (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:320591)
    at ge (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:210033)
    at J (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:200233)
    at X (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:201305)
[BG]   checking: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py (909ms)
[BG] analyzing: /Users/friedrichb/repo/loco-api/src/loco/db/models/bases.py (1155ms)
[Error - 6:51:39 AM] Error performing analysis: Error: Debug Failure. False expression.
    at it (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:273786)
    at /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:302286
    at /Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:302238
    at zt (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:302278)
    at Ut (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:301950)
    at tn (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:319604)
    at nn (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:320591)
    at ge (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:210033)
    at J (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:200233)
    at X (/Users/friedrichb/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/pyright.bundle.js:1:201305)

Code Snippet / Additional information

image

# throws error
from __future__ import annotations

class Foo:
    def dict(self) -> dict:
        return {}
# throws error
from __future__ import annotations

class Foo:
    def list(self) -> list:
        return {}
# does NOT throw error
from __future__ import annotations

class Foo:
    def dict(self) -> list:
        return []
# does NOT throw error
from __future__ import annotations
from typing import Dict


class Foo:
    def dict(self) -> Dict:
        return {}

Thanks!

@erictraut
Copy link
Contributor

erictraut commented Jul 28, 2020

Thanks for the bug report. This is a crash caused by a circular reference. You are defining a symbol (dict) whose definition refers to itself via the return parameter type annotation. This fix will be in the next version of Pylance.

That said, your code contains a bug that you will need to fix. When a type annotation is quoted or you use the "annotations" future, the type annotation no longer honors "code flow order". Instead, the type checker looks up the symbol in the current scope even if the symbol is declared later in that scope. In your case, you are defining the symbol dict within the scope of Foo, so any type annotation within that class that uses forward declarations will use the redeclared version of dict within that scope.

There are a few easy workarounds. These will also avoid the bug while you're waiting for the fix.

Option 1:

import builtins

class Foo:
    def dict(self) -> builtins.dict:
        return {}

Option 2:

from builtins import dict as builtin_dict

class Foo:
    def dict(self) -> builtin_dict:
        return {}

Option 3: Choose a better name for your local method — one that doesn't match a built-in type name!

@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 labels Jul 28, 2020
@la-mar
Copy link
Author

la-mar commented Jul 28, 2020

Makes a lot of sense! Thanks for the feedback!

@jakebailey
Copy link
Member

This issue has been fixed in version 2020.7.4, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202074-29-july-2020

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

3 participants