Closed zengjiapei3000 closed 1 year ago
In VScode did you use open folder on the top grains
folder? or on a different parent folder?
please update with pylance logs see "Python Language Server" output logs see https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue
In VScode did you use open folder on the top grains folder? correct. or on a different parent folder? I didn't.
Here is my pylance logs:
[Info - 7:16:01 PM] (9112) Could not import 'grains.g' in file 'c:\Users\ash_258\Exercism\python\grains\grains_test.py'
[Info - 7:16:01 PM] (9112) Looking in stubPath 'c:\Users\ash_258\Exercism\python\typings'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'c:\Users\ash_258\Exercism\python\typings'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'c:\Users\ash_258\Exercism\python\typings'
[Info - 7:16:01 PM] (9112) Looking in root directory of execution environment 'c:\Users\ash_258\Exercism\python'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'c:\Users\ash_258\Exercism\python'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'c:\Users\ash_258\Exercism\python'
[Info - 7:16:01 PM] (9112) Finding python search paths
[Info - 7:16:01 PM] (9112) Executing interpreter: 'c:\Users\ash_258\Exercism\python\.venv\Scripts\python.exe'
[Info - 7:16:01 PM] (9112) Skipping 'D:\Applications\Scoop\apps\python\current\python311.zip' because it is not a valid directory
[Info - 7:16:01 PM] (9112) Received 5 paths from interpreter
[Info - 7:16:01 PM] (9112) D:\Applications\Scoop\apps\python\current\DLLs
[Info - 7:16:01 PM] (9112) D:\Applications\Scoop\apps\python\current\Lib
[Info - 7:16:01 PM] (9112) D:\Applications\Scoop\apps\python\current
[Info - 7:16:01 PM] (9112) c:\Users\ash_258\Exercism\python\.venv
[Info - 7:16:01 PM] (9112) c:\Users\ash_258\Exercism\python\.venv\Lib\site-packages
[Info - 7:16:01 PM] (9112) Looking in python search path 'd:\Applications\Scoop\apps\python\3.11.3\DLLs'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'd:\Applications\Scoop\apps\python\3.11.3\DLLs'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'd:\Applications\Scoop\apps\python\3.11.3\DLLs'
[Info - 7:16:01 PM] (9112) Looking in python search path 'd:\Applications\Scoop\apps\python\3.11.3\Lib'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'd:\Applications\Scoop\apps\python\3.11.3\Lib'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'd:\Applications\Scoop\apps\python\3.11.3\Lib'
[Info - 7:16:01 PM] (9112) Looking in python search path 'd:\Applications\Scoop\apps\python\3.11.3'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'd:\Applications\Scoop\apps\python\3.11.3'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'd:\Applications\Scoop\apps\python\3.11.3'
[Info - 7:16:01 PM] (9112) Looking in python search path 'c:\Users\ash_258\Exercism\python\.venv'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'c:\Users\ash_258\Exercism\python\.venv'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'c:\Users\ash_258\Exercism\python\.venv'
[Info - 7:16:01 PM] (9112) Looking in python search path 'c:\Users\ash_258\Exercism\python\.venv\Lib\site-packages'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'c:\Users\ash_258\Exercism\python\.venv\Lib\site-packages'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'c:\Users\ash_258\Exercism\python\.venv\Lib\site-packages'
[Info - 7:16:01 PM] (9112) Looking in bundled stubs path 'D:\Applications\Scoop\persist\vscode\data\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info - 7:16:01 PM] (9112) Attempting to resolve stub package using root path 'D:\Applications\Scoop\persist\vscode\data\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'D:\Applications\Scoop\persist\vscode\data\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info - 7:16:01 PM] (9112) Looking for typeshed stdlib path
[Info - 7:16:01 PM] (9112) Looking for typeshed stdlib path
[Info - 7:16:01 PM] (9112) Attempting to resolve using root path 'D:\Applications\Scoop\persist\vscode\data\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib'
[Info - 7:16:01 PM] (9112) Typeshed path not found
[Info - 7:16:01 PM] (9112) Looking for typeshed third-party path
[Info - 7:16:01 PM] (9112) Looking for typeshed stubs path
[Info - 7:16:01 PM] (9112) Typeshed path not found
(9112) [FG] binding: c:\Users\ash_258\Exercism\python\grains\grains_test.py (1ms)
(9112) [FG] completion at c:\Users\ash_258\Exercism\python\grains\grains_test.py:2:13 [found 2 items] (4ms)
(9112) IntelliCode: current invocation did not produce any meaningful tokens.
(9112) Time taken to get recommendations: 3 ms, Memory increase: 140 KB.
(9112) Background analysis message: setFileOpened
(9112) Background analysis message: markFilesDirty
(9112) Background analysis message: getDiagnosticsForRange
(9112) Background analysis message: getDiagnosticsForRange
(9112) Background analysis message: setFileOpened
(9112) Background analysis message: markFilesDirty
(9112) [FG] parsing: c:\Users\ash_258\Exercism\python\grains\grains_test.py (2ms)
(9112) [FG] binding: c:\Users\ash_258\Exercism\python\grains\grains_test.py (1ms)
(9112) Background analysis message: analyze
(9112) [BG(1)] analyzing: c:\Users\ash_258\Exercism\python\grains\grains_test.py ...
(9112) [BG(1)] parsing: c:\Users\ash_258\Exercism\python\grains\grains_test.py (2ms)
(9112) [BG(1)] binding: c:\Users\ash_258\Exercism\python\grains\grains_test.py (0ms)
(9112) [BG(1)] checking: c:\Users\ash_258\Exercism\python\grains\grains_test.py (26ms)
(9112) [BG(1)] analyzing: c:\Users\ash_258\Exercism\python\grains\grains_test.py (28ms)
(9112) Background analysis message: getDiagnosticsForRange
(9112) Background analysis message: resumeAnalysis
(9112) [BG(1)] indexing: c:\Users\ash_258\Exercism\python\grains\grains_test.py [found 1] (0ms)
(9112) Indexing Done: c:\Users\ash_258\Exercism\python\grains\grains_test.py
(9112) Background analysis message: getDiagnosticsForRange
(9112) Background analysis message: getDiagnosticsForRange
(9112) Background analysis message: getDiagnosticsForRange
[Info - 7:16:02 PM] (9112) SourceFile: Received fs event 'change' for path 'c:\Users\ash_258\Exercism\python\grains\grains_test.py'
(9112) Background analysis message: markFilesDirty
(9112) Background analysis message: analyze
this is because grains
package takes precedence
over 'module' since your root
is parent folder
of grains
folder.
if you want grains
to refer to the module, you either need to open grains
as the root
or use settings
to put gains
as one of import search root
one way of doing that is adding this to settings.json
{
"python.analysis.extraPaths": ["grains"]
}
or you could create pyrightconfig.json
file at the root
with this content or others.
{
"executionEnvironments": [ { "root": "grains"}]
}
it doesn't matter which way you choose, but you need to tell pylance
that you want us to consider nested folder
as search paths
Type: Bug
Behaviour
here is full folder layout: ├─grains │ |─pycache │ |─grains_test.py │ └─grains.py
when I edit
grains_test.py
, that I addfrom grains import square
sentence, the feature of "GoToDefinition" not work when I want to gotosquare
definition.But when I change the sentence to
from grains.grains import square
the feature can work.Expected vs. Actual
XXX
Steps to reproduce:
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)``` XXX ```
User Settings
``` languageServer: "Pylance" linting • enabled: false • flake8Args: ""
• flake8Enabled: true
testing
• pytestArgs: ""
• unittestArgs: ""
• unittestEnabled: true
```
Extension version: 2023.6.0 VS Code version: Code 1.77.1 (b7886d7461186a5eac768481578c1d7ca80e2d21, 2023-04-04T23:21:11.906Z) OS version: Windows_NT x64 10.0.19044 Modes: Sandboxed: No
System Info
|Item|Value| |---|---| |CPUs|AMD Ryzen 7 5800H with Radeon Graphics (16 x 3194)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|63.86GB (55.27GB free)| |Process Argv|| |Screen Reader|no| |VM|67%|