Skip to content

Make staticmethod/classmethod generic in their return type - #6285

Merged
srittau merged 2 commits into
python:masterfrom
AlexWaygood:classmethod-staticmethod-generic
Nov 12, 2021
Merged

srittau merged 2 commits into
python:masterfrom
AlexWaygood:classmethod-staticmethod-generic

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Nov 12, 2021 •

Copy link
Copy Markdown
Member

This proposal is basically "make classmethod and staticmethod generic in such a way that we get more type specificity now, and it will also be easy to add ParamSpec once mypy supports it".

Slightly different to @srittau's approaches in #5703 and #5682

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pydantic (https://github.com/samuelcolvin/pydantic.git)
+ pydantic/class_validators.py:57: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:84: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:100: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:107: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:113: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:125: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:135: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/class_validators.py:328: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/main.py:869: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/main.py:882: error: Missing type parameters for generic type "classmethod"  [type-arg]
+ pydantic/main.py:894: error: Missing type parameters for generic type "classmethod"  [type-arg]

@srittau
srittau merged commit 16a76a6 into python:master Nov 12, 2021
@AlexWaygood
AlexWaygood deleted the classmethod-staticmethod-generic branch November 12, 2021 16:35
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