Skip to content

Improve stubs for classmethod and staticmethod #10421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

AlexWaygood
Copy link
Member

Fixes #10396

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

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
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