Skip to content

Mark enum constants in signal.py as Final, not Literal#13500

Merged
sobolevn merged 3 commits into
mainfrom
signal-enums
Jul 31, 2025
Merged

Mark enum constants in signal.py as Final, not Literal#13500
sobolevn merged 3 commits into
mainfrom
signal-enums

Conversation

@sobolevn

Copy link
Copy Markdown
Member

PR #13336 caused a regression in mypy, see python/mypy#18628

So, I changed Literal to Final, since it works and added a test case for the regression.

@github-actions

This comment has been minimized.

@AlexWaygood

Copy link
Copy Markdown
Member

The change basically LGTM, but pytype is crashing. Also, pyright has quite different inference for generic parameters compared to mypy, so I think we'll struggle to find a test case test demonstrates the issue clearly while passing on both mypy and pyright. I'd be tempted to just skip the test case, personally.

@github-actions

This comment has been minimized.

@sobolevn

Copy link
Copy Markdown
Member Author

Any ideas on what's wrong?

stdlib/signal.pyi (3.12): pytype.pytd.visitors.LiteralValueError: In Literal[SIG_DFL]: builtins.int is not an enum and cannot be used in typing.Literal

@AlexWaygood

Copy link
Copy Markdown
Member

looks like a pytype bug to me

@sobolevn

Copy link
Copy Markdown
Member Author

cc @rchen152

@AlexWaygood

Copy link
Copy Markdown
Member

cc @rchen152

I don't think Rebecca works on pytype anymore :-) maybe @frigus02 could take a look?

@frigus02

Copy link
Copy Markdown
Contributor

I don't work on pytype anymore, either. Maybe @h-joo?

@AlexWaygood

Copy link
Copy Markdown
Member

I don't work on pytype anymore, either.

Oh, sorry!

@Avasam Avasam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We've removed support for pytype. If this passes tests I'm happy with this.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@sobolevn sobolevn merged commit 07bbe5e into main Jul 31, 2025
63 checks passed
@sobolevn sobolevn deleted the signal-enums branch July 31, 2025 09:13
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.

4 participants