Skip to content

Switch order of dataclass decorator overloads#9743

Merged
hauntsaninja merged 2 commits into
python:mainfrom
koogoro:switch-order-of-dataclass-decorator-overloads
Feb 17, 2023
Merged

Switch order of dataclass decorator overloads#9743
hauntsaninja merged 2 commits into
python:mainfrom
koogoro:switch-order-of-dataclass-decorator-overloads

Conversation

@koogoro

@koogoro koogoro commented Feb 16, 2023

Copy link
Copy Markdown
Contributor

When type checking in a non-strict Optional context where None inhabits all types, the type[_T]-type overload will always resolve over the None-type overload. Switching the order of these better represents the priority of overloads when running in this context. mypy ensures that listing an overload with a None argument second in non-strict-optional order results in a type error: https://github.com/python/mypy/blob/83660d0ad72ab5a61cea5fe5955e66c33ef54111/test-data/unit/check-overloading.test#L4619

@hauntsaninja hauntsaninja 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.

Ooo, --no-strict-optional in 2023 is bold ;-) But this looks good, thank you!

@hauntsaninja

Copy link
Copy Markdown
Collaborator

You can ignore CI failures, they're related to new Python versions being released and will be fixed by #9742

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

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

@hauntsaninja
hauntsaninja merged commit 75cd302 into python:main Feb 17, 2023
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.

2 participants