Open T-256 opened 1 month ago
@T-256 Although there might be a bug here that affects supported version of python. Python extension supports only active version of python: https://devguide.python.org/versions/#supported-versions.
Moving this to Pylance to investigate completion issue.
Those errors are not being reported by Pylance. We don't have the string 'Undefined name' anywhere in our code.
For me, that's what Ruff reports:
@karthiknadig Correct, but I also can repro on Python 3.8 and 3.9.
@rchiodo the issue here is not reported violations, it's about that Pylance should not suggest anext
in suggestion list because selected interpreter's version is below 3.10 and anext
introuduced in 3.10.
(As far as I know Ruff doesn't have capability to provide suggestions.)
Can you do this in the REPL?
import sys
sys.version
For me, the interpreter is not the one I set in my python file, it's always the global python. That would explain why Pylance is getting the wrong completion output.
It's correct for notebook:
Can you do this in the REPL?
Oh the Python REPL lets me change it. If I force it to 3.9, I don't get anext
in the completions:
Can you include the output of the Python Language Server
. Although it would include all the other files and notebooks you have open. It would be best to include the output after closing all windows, then clear the Python Language Server
output, and then create a Python REPL.
Pylance thinks the REPL is using a Python greater then 3.10, but the output should show which interpreter it's being told is in use.
Logs by open new window and run start native python REPL
command:
2024-10-07 21:23:40.508 [info] Telemetry level is off
2024-10-07 21:23:40.508 [info] Experiments are disabled, only manually opted experiments are active.
2024-10-07 21:23:40.508 [info] Python interpreter path: C:\Python37x86\python.exe
2024-10-07 21:23:41.255 [info] > conda info --json
2024-10-07 21:23:42.316 [info] Starting Pylance language server.
2024-10-07 21:23:41.776 [info] (Client) Pylance async client (2024.9.2) started with python extension (2024.16.0)
2024-10-07 21:23:42.305 [info] [Info - 9:23:42 PM] (35288) Server root directory: file:///c%3A/Users/Tester/.vscode/extensions/ms-python.vscode-pylance-2024.9.2/dist
2024-10-07 21:23:42.305 [info] [Info - 9:23:42 PM] (35288) Pylance language server 2024.9.2 (pyright version 1.1.378, commit ce64adc1) starting
2024-10-07 21:23:42.325 [info] [Info - 9:23:42 PM] (35288) Starting service instance "<default>"
2024-10-07 21:23:42.339 [info] [Info - 9:23:42 PM] (35288) Setting environmentName for service "<default>": "3.7.9 (global)"
2024-10-07 21:23:42.340 [info] [Info - 9:23:42 PM] (35288) Setting pythonPath for service "<default>": "c:\Users\Tester\.vscode\extensions\ms-python.vscode-pylance-2024.9.2\dist"
2024-10-07 21:23:42.340 [info] [Info - 9:23:42 PM] (35288) No include entries specified; assuming \<default workspace root>
2024-10-07 21:23:42.340 [info] [Info - 9:23:42 PM] (35288) Auto-excluding **/node_modules
2024-10-07 21:23:42.341 [info] [Info - 9:23:42 PM] (35288) Auto-excluding **/__pycache__
2024-10-07 21:23:42.341 [info] [Info - 9:23:42 PM] (35288) Auto-excluding **/.*
2024-10-07 21:23:42.389 [info] [Error - 9:23:42 PM] (35288) File or directory "\<default workspace root>" does not exist.
2024-10-07 21:23:42.389 [info] [Info - 9:23:42 PM] (35288) No source files found.
2024-10-07 21:23:42.734 [info] [Info - 9:23:42 PM] (35288) Background analysis(1) root directory: file:///c%3A/Users/Tester/.vscode/extensions/ms-python.vscode-pylance-2024.9.2/dist
2024-10-07 21:23:42.736 [info] [Info - 9:23:42 PM] (35288) Background analysis(1) started
2024-10-07 21:23:40.509 [info] Starting Python Locator c:\Users\Tester\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\python-env-tools\bin\pet.exe server
2024-10-07 21:23:40.511 [warning] Failed to open HKLM\Software\Python, Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }
2024-10-07 21:23:40.511 [info] Discovered env: C:\Python310\python.exe
2024-10-07 21:23:40.512 [info] Discovered env: C:\Python311\python.exe
2024-10-07 21:23:40.512 [info] Discovered env: C:\Python311x86\python.exe
2024-10-07 21:23:40.512 [info] Discovered env: C:\Python312\python.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python312x86\python.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python313\python.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python313\python3.13t.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python37\python.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python37x86\python.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python38\python.exe
2024-10-07 21:23:40.513 [info] Discovered env: C:\Python39\python.exe
2024-10-07 21:23:40.514 [info] Discovered env: C:\Users\Tester\.virtualenvs\Crash256-fkIDZCnG\Scripts\python.exe
2024-10-07 21:23:40.514 [error] Python Execution for "C:\\Users\\Tester\\.rye\\shims\\python.exe" produced an output "" without a separator
2024-10-07 21:23:40.514 [warning] Unknown Python Env "C:\\Users\\Tester\\.rye\\shims\\python.exe"
2024-10-07 21:23:40.811 [error] Python Execution for "C:\\Users\\Tester\\.rye\\shims\\python3.exe" produced an output "" without a separator
2024-10-07 21:23:40.811 [warning] Unknown Python Env "C:\\Users\\Tester\\.rye\\shims\\python3.exe"
2024-10-07 21:23:40.811 [info] Locator Conda took 124.1983ms
2024-10-07 21:23:40.811 [info] Locator PipEnv took 157.4µs
2024-10-07 21:23:40.811 [info] Locator Poetry took 2.2856ms
2024-10-07 21:23:40.812 [info] Locator PyEnv took 1.3322ms
2024-10-07 21:23:40.812 [info] Locator Venv took 142.7µs
2024-10-07 21:23:40.812 [info] Locator VirtualEnv took 494.1µs
2024-10-07 21:23:40.812 [info] Locator VirtualEnvWrapper took 431.4µs
2024-10-07 21:23:40.812 [info] Locator WindowsRegistry took 8.1668ms
2024-10-07 21:23:40.812 [info] Locator WindowsStore took 884.7µs
2024-10-07 21:23:40.812 [info] Locator GlobalVirtualEnvs took 9.5966ms
2024-10-07 21:23:40.812 [info] Locator Locators took 124.5172ms
2024-10-07 21:23:40.812 [info] Locator Path took 367.0248ms
2024-10-07 21:23:40.812 [info] Locator Workspaces took 1.1µs
2024-10-07 21:23:40.812 [info] Refresh completed in 367ms
FWIW, I'm using these settings:
"python.defaultInterpreterPath": "C:\\Python37x86\\python.exe",
"python.REPL.sendToNativeREPL": true,
-- Notebook with explicitly selected kernel
++ Notebook no kernel selected / Python REPL
- 2024-10-07 21:30:46.590 [info] [Info - 9:30:46 PM] (35288) Setting pythonPath for service "<default>": "c:\Python37x86\python.exe"
+ 2024-10-07 21:23:42.340 [info] [Info - 9:23:42 PM] (35288) Setting pythonPath for service "<default>": "c:\Users\Tester\.vscode\extensions\ms-python.vscode-pylance-2024.9.2\dist"
Yeah, this seems like the problem:
"c:\Users\Tester\.vscode\extensions\ms-python.vscode-pylance-2024.9.2\dist"
That's not a valid pythonPath. Not sure where it's coming from. It looks like it's using the current working directory for some reason. Internally that would likely just cause us to call 'python' by itself to compute the site-packages and version information.
Type: Bug
Behavior
Inconsistent suggestions
Steps to reproduce:
an
anext
suggestion and press EnterDiagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)``` XXX ```
Behaviour
XXX
Steps to reproduce:
Diagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)``` XXX ```
Extension version: 2024.16.0 VS Code version: Code 1.94.0 (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z) OS version: Windows_NT x64 10.0.22631 Modes:
python.languageServer
setting: DefaultUser Settings
``` languageServer: "Pylance" ```
Installed Extensions
|Extension Name|Extension Id|Version| |---|---|---| |Bracket Select|chunsen.bracket-select|2.0.2| |CodeSnap|adpyke.codesnap|1.3.4| |Convert To ASCII Art|BitBelt.converttoasciiart|1.0.3| |Error Lens|usernamehw.errorlens|3.20.0| |Fast Compare|DavidKol.fastcompare|1.2.1| |Fluent Icons|miguelsolorio.fluent-icons|0.0.18| |Git History|donjayamanne.githistory|0.6.20| |Hex Editor|ms-vscode.hexeditor|1.10.0| |Indent Nested Dictionary|mgesbert.indent-nested-dictionary|0.0.4| |JavaScript Debugger|ms-vscode.js-debug|1.94.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.3| |Jupyter|ms-toolsai.jupyter|2024.9.1| |Material Icon Theme|PKief.material-icon-theme|5.11.1| |Modern Chromo|undefined_publisher.modern-chromo|0.0.1| |Pylance|ms-python.vscode-pylance|2024.9.2| |Python|ms-python.python|2024.16.0| |Python Brackets|OrangeX4.python-brackets|1.4.2| |Python Debugger|ms-python.debugpy|2024.6.0| |Python Paste And Indent|hyesun.py-paste-indent|0.3.0| |Ruff|charliermarsh.ruff|2024.50.0| |Select Line Status Bar|tomoki1207.selectline-statusbar|0.0.2| |Swap Selection with Clipboard|LukaszPolowczyk.swap-selection-with-clipboard|1.2.6| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.10| |Trailing Spaces|shardulm94.trailing-spaces|0.4.1| |WSL|ms-vscode-remote.remote-wsl|0.88.4|