GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-132457: make staticmethod and classmethod generic by IvanKirpichnikov · Pull Request #132460 · python/cpython

Conversation

@IvanKirpichnikov

@IvanKirpichnikov IvanKirpichnikov commented Apr 12, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Consider making staticmethod and classmethod generic #132457

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@IvanKirpichnikov
add Py_GenericAlias for staticmethod and classmethod
ae58b1a
@python-cla-bot

python-cla-bot Bot commented Apr 12, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Apr 12, 2025
@bedevere-app

bedevere-app Bot commented Apr 12, 2025

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Apr 12, 2025
Consider making staticmethod and classmethod generic #132457
Closed
@picnixz

This comment was marked as resolved.

Sign in to view
@picnixz picnixz closed this Apr 12, 2025
@sobolevn

This comment was marked as resolved.

Sign in to view
@sobolevn sobolevn reopened this Apr 12, 2025
@bedevere-app

bedevere-app Bot commented Apr 12, 2025

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IvanKirpichnikov
IvanKirpichnikov marked this pull request as draft April 12, 2025 22:38
@bedevere-app bedevere-app Bot removed the awaiting review label Apr 12, 2025
@IvanKirpichnikov
Add news
5639738
@sobolevn
sobolevn requested review from AlexWaygood, JelleZijlstra and hauntsaninja April 28, 2025 22:49
@sobolevn
sobolevn marked this pull request as ready for review April 28, 2025 22:51
@bedevere-app bedevere-app Bot added the awaiting review label Apr 28, 2025
@AlexWaygood

AlexWaygood commented Apr 29, 2025

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood
AlexWaygood removed their request for review April 29, 2025 09:54
@IvanKirpichnikov

IvanKirpichnikov commented Apr 29, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IvanKirpichnikov
Merge branch 'main' into feature/add_genericalias_for_sm_cm
c32532e
JelleZijlstra
JelleZijlstra reviewed May 4, 2025
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sobolevn
sobolevn approved these changes May 4, 2025
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 4, 2025
@sobolevn
Merge branch 'main' into feature/add_genericalias_for_sm_cm
abf85c6
@sobolevn
sobolevn merged commit a363675 into python:main May 4, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label May 4, 2025
diegorusso added a commit to diegorusso/cpython that referenced this pull request May 4, 2025
@diegorusso
Merge remote-tracking branch 'origin/main' into call-len
c03babc
* 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)
  ...
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@IvanKirpichnikov @sobolevn @Pranjal095
pythongh-132457: make staticmethod and classmethod generic (python#13…
318bb66
…2460)

Co-authored-by: sobolevn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments
@sobolevn sobolevn sobolevn approved these changes
@hauntsaninja hauntsaninja Awaiting requested review from hauntsaninja

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@IvanKirpichnikov @picnixz @sobolevn @AlexWaygood @JelleZijlstra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.