microsoft / microsoft/pyright

Remove unsafe type narrowing for non-closed TypedDicts

Open
#10,805 8 comments 0 reactions 0 assignees View on GitHub
enhancement request
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

[This issue](https://github.com/microsoft/pyright/issues/10517) attempted to fix a type checking hole related to TypedDict discrimination, but I reverted it because there was no clean way to implement this pattern without PEP 728. Now that PEP 728 is accepted, this unsafe behavior should be reverted.

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked issue #10517 and the details of PEP 728 to understand the earlier TypedDict discrimination fix and why it was reverted. Confirm the intended behavior for non-closed TypedDicts, then verify that unsafe narrowing is no longer accepted with relevant type-checking cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.