Skip to content

Refactor PEP 661 sentinel handling to use a synthetic nominal class - #21894

Draft
edgarrmondragon wants to merge 1 commit into
python:masterfrom
edgarrmondragon:sentinel-nominal-types
Draft

Refactor PEP 661 sentinel handling to use a synthetic nominal class#21894
edgarrmondragon wants to merge 1 commit into
python:masterfrom
edgarrmondragon:sentinel-nominal-types

Conversation

@edgarrmondragon

@edgarrmondragon edgarrmondragon commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@github-actions

This comment has been minimized.

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
@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

Copy link
Copy Markdown
Member

I guess you want to cc @JelleZijlstra here.

@JelleZijlstra

Copy link
Copy Markdown
Member

If this fits better in mypy's model, I'm OK with landing it, but it feels worse to me. A sentinel isn't its own type, it's a single object that is an instance of the type sentinel. Treating it more like a literal makes more sense than treating it like a NewType.

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.

Invalid return type with sentinel and dict.get

3 participants