microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.67k stars 770 forks source link

Failure to notice bad quoting syntax #6038

Closed llamafilm closed 1 week ago

llamafilm commented 1 week ago

Type: Bug

Behaviour

Given this python code:

block = {'id': 123}
print(f'parent=="{block['id']}"')

That causes SyntaxError: f-string: unmatched '['

But the VS Code extension does not flag it as an error.

Extension version: 2023.20.0 VS Code version: Code 1.90.1 (Universal) (611f9bfce64f25108829dd295f54a6894e87339d, 2024-06-11T21:02:41.372Z) OS version: Darwin arm64 22.6.0 Modes: Remote OS version: Linux x64 6.5.0-1020-aws

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |JavaScript Debugger|ms-vscode.js-debug|1.90.0| |Pylance|ms-python.vscode-pylance|2024.6.1| |Python|ms-python.python|2024.8.1| |Python Debugger|ms-python.debugpy|2024.6.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9|
System Info |Item|Value| |---|---| |CPUs|Apple M2 Pro (12 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (0.07GB free)| |Process Argv|. --crash-reporter-id 11e589b2-48d6-4af6-9407-725f0132c526| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: %msenetbox,prod| |OS|Linux x64 6.5.0-1020-aws| |CPUs|Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz (2 x 0)| |Memory (System)|7.63GB (4.63GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 jchc7451:31067544 chatpanelc:31048052 dsvsc021:30996838 0ee40948:31013168 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 legacy_priority:31077528 ```
rchiodo commented 1 week ago

Thanks for the issue. This error is actually enabled if you turn on basic type checking:

"python.analysis.typeCheckingMode" : "basic"

image

In the default "off", this isn't flagged as an error.

rchiodo commented 1 week ago

Alternatively that is valid syntax in 3.12, so you could switch to 3.12.