Skip to content

gh-132457: make staticmethod and classmethod generic #132460

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

Conversation

IvanKirpichnikov
Copy link
Contributor

@IvanKirpichnikov IvanKirpichnikov commented Apr 12, 2025

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 12, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Apr 12, 2025

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.

@picnixz picnixz closed this Apr 12, 2025
@sobolevn

This comment was marked as resolved.

@sobolevn sobolevn reopened this Apr 12, 2025
@bedevere-app
Copy link

bedevere-app bot commented Apr 12, 2025

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.

@IvanKirpichnikov IvanKirpichnikov marked this pull request as draft April 12, 2025 22:38
@sobolevn sobolevn marked this pull request as ready for review April 28, 2025 22:51
@AlexWaygood
Copy link
Member

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.

@AlexWaygood AlexWaygood removed their request for review April 29, 2025 09:54
@IvanKirpichnikov
Copy link
Contributor Author

IvanKirpichnikov commented Apr 29, 2025

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

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

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

Copy link
Member

@sobolevn sobolevn left a comment

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!

@sobolevn sobolevn merged commit a363675 into python:main May 4, 2025
42 checks passed
diegorusso added a commit to diegorusso/cpython that referenced this pull request May 4, 2025
* origin/main: (111 commits)
  pythongh-91048: Add filename and line number to external inspection routines (pythonGH-133385)
  pythongh-131178: Add tests for `ast` command-line interface (python#133329)
  Regenerate pcbuild.sln in Visual Studio 2022 (python#133394)
  pythongh-133042: disable HACL* HMAC on Emscripten (python#133064)
  pythongh-133351: Fix remote PDB's multi-line block tab completion (python#133387)
  pythongh-109700: Improve stress tests for interpreter creation (pythonGH-109946)
  pythongh-81793: Skip tests for os.link() to symlink on Android (pythonGH-133388)
  pythongh-126835: Rename `ast_opt.c` to `ast_preprocess.c` and related stuff after moving const folding to the peephole optimizier (python#131830)
  pythongh-91048: Relax test_async_global_awaited_by to fix flakyness (python#133368)
  pythongh-132457: make staticmethod and classmethod generic (python#132460)
  pythongh-132805: annotationlib: Fix handling of non-constant values in FORWARDREF (python#132812)
  pythongh-132426: Add get_annotate_from_class_namespace replacing get_annotate_function (python#132490)
  pythongh-81793: Always call linkat() from os.link(), if available (pythonGH-132517)
  pythongh-122559: Synchronize C and Python implementation of the io module about pickling (pythonGH-122628)
  pythongh-69605: Add PyREPL import autocomplete feature to 'What's New' (python#133358)
  bpo-44172: Keep reference to original window in curses subwindow objects (pythonGH-26226)
  pythonGH-133231: Changes to executor management to support proposed `sys._jit` module (pythonGH-133287)
  pythongh-133363: Fix Cmd completion for lines beginning with `! ` (python#133364)
  pythongh-132983: Introduce `_zstd` bindings module (pythonGH-133027)
  pythonGH-91048: Add utils for printing the call stack for asyncio tasks (python#133284)
  ...
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.

5 participants