Skip to content

Improve stubs for classmethod and staticmethod - #10421

Merged
srittau merged 1 commit into
python:mainfrom
AlexWaygood:classmethod
Jul 19, 2023
Merged

srittau merged 1 commit into
python:mainfrom
AlexWaygood:classmethod

Conversation

@AlexWaygood

Copy link
Copy Markdown
Member

Fixes #10396

@github-actions

github-actions Bot commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

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

ibis (https://github.com/ibis-project/ibis)
+ ibis/common/grounds.py:30: error: Need type annotation for "__create__"  [var-annotated]
- ibis/common/grounds.py:93: note:          classmethod[type, [VarArg(Any), KwArg(Any)], Any]
+ ibis/common/grounds.py:93: note:          classmethod[Any, [VarArg(Any), KwArg(Any)], Any]
- ibis/common/grounds.py:96: error: Argument 1 to "__get__" of "classmethod" has incompatible type "None"; expected "type"  [arg-type]
- ibis/common/grounds.py:96: error: Argument 2 to "__get__" of "classmethod" has incompatible type "type[Annotable]"; expected "type[type] | None"  [arg-type]
- ibis/common/grounds.py:102: error: Argument 1 to "__get__" of "classmethod" has incompatible type "None"; expected "type"  [arg-type]
- ibis/common/grounds.py:102: error: Argument 2 to "__get__" of "classmethod" has incompatible type "type[Annotable]"; expected "type[type] | None"  [arg-type]
- ibis/common/grounds.py:175: note:          classmethod[type, [VarArg(Any), KwArg(Any)], Any]
+ ibis/common/grounds.py:175: note:          classmethod[Any, [VarArg(Any), KwArg(Any)], Any]
- ibis/common/grounds.py:180: error: Argument 1 to "__get__" of "classmethod" has incompatible type "None"; expected "type"  [arg-type]
- ibis/common/grounds.py:180: error: Argument 2 to "__get__" of "classmethod" has incompatible type "type[Singleton]"; expected "type[type] | None"  [arg-type]

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/results.py:400: note:          abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:400: note:          abstractclassmethod[BaseResult[R], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
- src/prefect/results.py:437: note:          abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:437: note:          abstractclassmethod[BaseResult[R], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
- src/prefect/results.py:509: note:          abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:509: note:          abstractclassmethod[BaseResult[R], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/id.py:274: error: Need type annotation for "__class_getitem__"  [var-annotated]

@AlexWaygood

Copy link
Copy Markdown
Member Author

Looks like this gets rid of a few false-positive errors in ibis.

@srittau
srittau merged commit 1088ab3 into python:main Jul 19, 2023
@AlexWaygood
AlexWaygood deleted the classmethod branch July 19, 2023 11:32
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.

classmethod typing is weird

2 participants