◐ Shell
clean mode source ↗

gh-132457: make staticmethod and classmethod generic by IvanKirpichnikov · Pull Request #132460 · python/cpython

@python-cla-bot

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz

This comment was marked as resolved.

@sobolevn

This comment was marked as resolved.

@bedevere-app

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@sobolevn sobolevn marked this pull request as ready for review

April 28, 2025 22:51

@AlexWaygood

I think it's pretty rare for people to use staticmethod and classmethod in annotations. But I do think it's generally good for the runtime and typeshed to agree with each other on whether a class is generic, so I'm weakly in favour of this PR. It doesn't really add a maintenance burden, and they've been generic in typeshed for a long time now without complaints from type-checker users. +0.5 from me.

@IvanKirpichnikov

I think it's pretty rare for people to use staticmethod and classmethod in annotations. But I do think it's generally good for the runtime and typeshed to agree with each other on whether a class is generic, so I'm weakly in favour of this PR. It doesn't really add a maintenance burden, and they've been generic in typeshed for a long time now without complaints from type-checker users. +0.5 from me.

Thank you for the plus.
However, the use of staticmethod and classmethod is found in the dishka library (here). I discovered this defect when I was fixing bugs in mypy

JelleZijlstra

Choose a reason for hiding this comment

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

I feel similarly to Alex

sobolevn

Choose a reason for hiding this comment

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

I am also in favor of this PR, since you also have a real use-case it also boosts my confidence. Moreover, the PR is rather simple and understand and maintain.

Thank you!

diegorusso added a commit to diegorusso/cpython that referenced this pull request

May 4, 2025

Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request

Jul 12, 2025
…2460)

Co-authored-by: sobolevn <mail@sobolevn.me>