Skip to content

Prevent crash on partial type inferred by a nested expression - #22190

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
ilevkivskyi:fix-partial-nested-rvalue
Oct 13, 2026
Merged

ilevkivskyi merged 1 commit into
python:masterfrom
ilevkivskyi:fix-partial-nested-rvalue

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Fixes #20792

In theory, any nested expression can infer a partial type. Although it is mostly a theoretical thing, it sometimes happens in real life, causing a crash. So it is better to prevent this whole class of crashes by guarding all relevant code paths (btw one of them was already guarded).

cc @JukkaL

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi
ilevkivskyi merged commit f5d467a into python:master Oct 13, 2026
25 checks passed
@ilevkivskyi
ilevkivskyi deleted the fix-partial-nested-rvalue branch October 13, 2026 16:54
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.

del partial_types[var] fails with KeyError: <Var 'errors' at 0x...>

2 participants