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

String literal type for variable causes incorrect hints for TypedDict keys #6801

Open
tabbea opened this issue Dec 28, 2024 · 0 comments
Open

Comments

@tabbea
Copy link

tabbea commented Dec 28, 2024

Type: Bug

Behaviour

Observed Behaviour

pyright gives the string literal(s) as the key hint(s)

Expected Behaviour

pyright should give the key(s) of the TypedDict as the key hint(s)

Steps to reproduce:

  1. Create a TypedDict
  2. Attempt to assign a TypedDict element to a variable typed as some string literal(s)
  3. Request a hint for the keys of the TypedDict

Screenshots

Image
Image

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Extension version: 2024.22.1
VS Code version: Code 1.96.2 (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2
Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.3
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Pylance
User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• autoTestDiscoverOnSaveEnabled: false

Installed Extensions
Extension Name Extension Id Version
Bash IDE mads-hartmann.bash-ide-vscode 1.43.0
Black Formatter ms-python.black-formatter 2024.4.0
Compare Folders moshfeu.compare-folders 0.25.1
Flake8 ms-python.flake8 2023.10.0
GitHub Pull Requests GitHub.vscode-pull-request-github 0.102.0
GitLens — Git supercharged eamodio.gitlens 16.1.1
Haskell haskell.haskell 2.4.4
Haskell Syntax Highlighting justusadam.language-haskell 3.6.0
isort ms-python.isort 2023.10.1
JavaScript Debugger ms-vscode.js-debug 1.96.0
LaTeX Workshop James-Yu.latex-workshop 10.7.1
Live Preview ms-vscode.live-server 0.4.15
LTeX – LanguageTool grammar/spell checking valentjn.vscode-ltex 13.1.0
macros geddski.macros 1.2.1
Markdown Preview Enhanced shd101wyy.markdown-preview-enhanced 0.8.15
Markmap gera2ld.markmap-vscode 0.2.2
Outline Map Gerrnperl.outline-map 1.4.1
Overtype DrMerfy.overtype 0.5.0
Partial Diff ryu1kn.partial-diff 1.4.3
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.22.1
Python Debugger ms-python.debugpy 2024.14.0
Rainbow CSV mechatroner.rainbow-csv 3.13.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
Todo Tree Gruntfuggly.todo-tree 0.0.226
Toggle rebornix.toggle 0.0.2
Word Count ms-vscode.wordcount 0.1.0
System Info
Item Value
CPUs AMD Ryzen 9 7900X 12-Core Processor (24 x 4691)
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.14GB (17.03GB free)
Process Argv --folder-uri vscode-remote://wsl%2Bubuntu/mnt/c/Users/win11pro/Documents/bea-drive/repos/thesis --crash-reporter-id b869d960-5c79-4cf8-aa6d-f72162f54a9f
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.15.167.4-microsoft-standard-WSL2
CPUs AMD Ryzen 9 7900X 12-Core Processor (24 x 0)
Memory (System) 15.19GB (11.94GB free)
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.15.167.4-microsoft-standard-WSL2
CPUs AMD Ryzen 9 7900X 12-Core Processor (24 x 0)
Memory (System) 15.19GB (11.94GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
9b8hh234:30694863
pythonnoceb:30805159
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupyter:31046869
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant