Skip to content

Fix TypedDict indexing with literal keys in comprehensions#21556

Merged
JukkaL merged 1 commit into
python:masterfrom
97littleleaf11:fix-19317
May 29, 2026
Merged

Fix TypedDict indexing with literal keys in comprehensions#21556
JukkaL merged 1 commit into
python:masterfrom
97littleleaf11:fix-19317

Conversation

@97littleleaf11
Copy link
Copy Markdown
Collaborator

Fixes #19317

Uses exsiting index narrowing in for-loop. Previous PR: #18014

@github-actions
Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/tests/unit/test_chains_aggregator.py:202: error: Unused "type: ignore" comment  [unused-ignore]

meson (https://github.com/mesonbuild/meson)
+ mesonbuild/modules/rust.py:830:60: error: Redundant cast to "Literal['c', 'cpp', 'cuda', 'fortran', 'd', 'objc', 'objcpp', 'rust', 'vala', 'cs', 'swift', 'java', 'cython', 'nasm', 'masm', 'linearasm']"  [redundant-cast]

Copy link
Copy Markdown
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@JukkaL JukkaL merged commit 94838b0 into python:master May 29, 2026
25 checks passed
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

Successfully merging this pull request may close these issues.

False positive when accessing a TypedDict in a list comprehension

2 participants