René's URL Explorer Experiment


Title: Is `Enum`'s `_generate_next_value_` really a `@staticmethod`? · Issue #10428 · python/typeshed · GitHub

Open Graph Title: Is `Enum`'s `_generate_next_value_` really a `@staticmethod`? · Issue #10428 · python/typeshed

X Title: Is `Enum`'s `_generate_next_value_` really a `@staticmethod`? · Issue #10428 · python/typeshed

Description: I was playing around with a custom enum and wanted to give it custom auto values. But come time to override _generate_next_value_ and pyright tells me that: Method "_generate_next_value_" overrides class "Enum" in an incompatible manner....

Open Graph Description: I was playing around with a custom enum and wanted to give it custom auto values. But come time to override _generate_next_value_ and pyright tells me that: Method "_generate_next_value_" overrides...

X Description: I was playing around with a custom enum and wanted to give it custom auto values. But come time to override _generate_next_value_ and pyright tells me that: Method "_generate_next_value_"...

Opengraph URL: https://github.com/python/typeshed/issues/10428

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Is `Enum`'s `_generate_next_value_` really a `@staticmethod`?","articleBody":"I was playing around with a custom enum and wanted to give it custom `auto` values. But come time to override `_generate_next_value_` and pyright tells me that: `Method \"_generate_next_value_\" overrides class \"Enum\" in an incompatible manner. Base method is declared as a staticmethod but override is not`.\r\n\r\nmypy:\r\n```\r\nerror: Signature of \"_generate_next_value_\" incompatible with supertype \"Enum\"  [override]\r\nnote:      Superclass:\r\nnote:          def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any\r\nnote:      Subclass:\r\nnote:          def _generate_next_value_(name, *_: Any) -> Any\r\n```\r\n\r\nThe following code in Python 3.9 works as expected, although with a type error:\r\n```py\r\nfrom enum import Enum, EnumMeta, auto, unique\r\nfrom typing import cast\r\nfrom typing_extensions import override\r\n\r\nclass CaptureMethodMeta(EnumMeta):\r\n    # Allow checking if simple string is enum\r\n    @override\r\n    def __contains__(self, other: object):\r\n        try:\r\n            self(other)\r\n        except ValueError:\r\n            return False\r\n        return True\r\n\r\n@unique\r\n# TODO: Replace with StrEnum in Python 3.11\r\nclass CaptureMethodEnum(str, Enum, metaclass=CaptureMethodMeta):\r\n    # Allow TOML to save as a simple string\r\n    @override\r\n    def __repr__(self):\r\n        return self.value\r\n    __str__ = __repr__\r\n\r\n    @override\r\n    def _generate_next_value_(name: str, *_):\r\n        return name\r\n\r\n    NONE = \"\"\r\n    BITBLT = auto()\r\n    WINDOWS_GRAPHICS_CAPTURE = auto()\r\n    PRINTWINDOW_RENDERFULLCONTENT = auto()\r\n    DESKTOP_DUPLICATION = auto()\r\n    VIDEO_CAPTURE_DEVICE = auto()\r\n\r\nbitblt: str = cast(str, \"BITBLT\")\r\nbar: str = cast(str, \"bar\")\r\nprint(bitblt == CaptureMethodEnum.BITBLT)\r\nprint(bar == CaptureMethodEnum.BITBLT)\r\nprint(\"BITBLT\" in CaptureMethodEnum)\r\nprint(\"bar\" in CaptureMethodEnum)\r\n```\r\n\r\nIf I decorate `_generate_next_value_` with `@staticmethod`, I get the following error:\r\n```\r\nTraceback (most recent call last):\r\n  File \"c:\\Users\\Avasam\\Desktop\\from enum import Enum, EnumMeta, unique.py\", line 18, in \u003cmodule>\r\n    class CaptureMethodEnum(str, Enum, metaclass=CaptureMethodMeta):\r\n  File \"c:\\Users\\Avasam\\Desktop\\from enum import Enum, EnumMeta, unique.py\", line 31, in CaptureMethodEnum\r\n    BITBLT = auto()\r\n  File \"C:\\Program Files\\Python39\\lib\\enum.py\", line 142, in __setitem__\r\n    value.value = self._generate_next_value(\r\nTypeError: 'staticmethod' object is not callable\r\n```\r\n","author":{"url":"https://github.com/Avasam","@type":"Person","name":"Avasam"},"datePublished":"2023-07-10T05:25:00Z","url":"https://github.com/python/typeshed/issues/10428"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:82c5db03-c15f-e274-3b66-b3c59ee96e51
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA7B8:BACA4:33F523C:4519AD5:6B0044A4
html-safe-nonce070f41dd11e6140c9e1dceaf4dcf25ccde8d3b224b7d378443090a661c8c4206
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0I4OkJBQ0E0OjMzRjUyM0M6NDUxOUFENTo2QjAwNDRBNCIsInZpc2l0b3JfaWQiOiIyNjU1MjcyNDM2MjkwODMxNTI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac26408ecb761152c6de01f3da259d9738d9df153930b8a57b484e51b912fd9ca0
hovercard-subject-tagissue:1795974999
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/10428/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e61e688b2499d78eb6e7f22fbd7845542f84b32afa4f8f6492709299cc59f503/python/typeshed/issues/10428
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e61e688b2499d78eb6e7f22fbd7845542f84b32afa4f8f6492709299cc59f503/python/typeshed/issues/10428
og:image:altI was playing around with a custom enum and wanted to give it custom auto values. But come time to override _generate_next_value_ and pyright tells me that: Method "_generate_next_value_" overrides...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAvasam
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/typeshed git https://github.com/python/typeshed.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id31696383
octolytics-dimension-repository_nwopython/typeshed
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31696383
octolytics-dimension-repository_network_root_nwopython/typeshed
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/10428#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F10428
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F10428
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/10428
Reloadhttps://github.com/python/typeshed/issues/10428
Reloadhttps://github.com/python/typeshed/issues/10428
pythonhttps://github.com/python
typeshedhttps://github.com/python/typeshed
Codehttps://github.com/python/typeshed
Issues196 (196)https://github.com/python/typeshed/issues
Pull requests252 (252)https://github.com/python/typeshed/pulls
Actionshttps://github.com/python/typeshed/actions
Security and qualityhttps://github.com/python/typeshed/security
Insightshttps://github.com/python/typeshed/insights
https://github.com/python/typeshed
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/10428
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/10428
Is Enum's _generate_next_value_ really a @staticmethod?https://github.com/python/typeshed/issues/10428#top
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
https://github.com/Avasam
Avasamhttps://github.com/Avasam
on Jul 10, 2023https://github.com/python/typeshed/issues/10428#issue-1795974999
https://github.com/srittau
srittauhttps://github.com/srittau
on Jul 10, 2023https://github.com/python/typeshed/issues/10428#issuecomment-1628752143
https://github.com/eltoder
eltoderhttps://github.com/eltoder
on Jul 11, 2023https://github.com/python/typeshed/issues/10428#issuecomment-1631657737
python/mypy#7591https://github.com/python/mypy/issues/7591
python 3.10 docshttps://docs.python.org/3.10/library/enum.html#using-automatic-values
python 3.11 docshttps://docs.python.org/3.11/library/enum.html#enum.Enum._generate_next_value_
https://github.com/Avasam
Avasamhttps://github.com/Avasam
on Jul 12, 2023https://github.com/python/typeshed/issues/10428#issuecomment-1631750128
https://github.com/eltoder
eltoderhttps://github.com/eltoder
on Jul 12, 2023https://github.com/python/typeshed/issues/10428#issuecomment-1631752042
AlexWaygoodhttps://github.com/AlexWaygood
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
on Jul 22, 2023https://github.com/python/typeshed/issues/10428#event-9891182644
https://github.com/jenstroeger
jenstroegerhttps://github.com/jenstroeger
on Aug 15, 2025https://github.com/python/typeshed/issues/10428#issuecomment-3190430357
Typing the _missing_ method of an StrEnum’s sub-class https://discuss.python.org/t/typing-the-missing-method-of-an-strenum-s-sub-class/
https://github.com/Avasam
Avasamhttps://github.com/Avasam
on May 18, 2026https://github.com/python/typeshed/issues/10428#issuecomment-4479802816
python/mypy#15382 (comment)https://github.com/python/mypy/issues/15382#issuecomment-4479783944
python/typeshed#10428https://github.com/python/typeshed/issues/10428
Drop support for --python-version 3.8 #19157https://github.com/python/mypy/pull/19157
mypy-lang.blogspot.com/2025/07/mypy-117-released.html#:~:text=Remove Support for Targeting Python 3.8https://mypy-lang.blogspot.com/2025/07/mypy-117-released.html#:~:text=Remove%20Support%20for%20Targeting%20Python%203.8
Drop support for --python-version 3.9 #21243https://github.com/python/mypy/pull/21243
mypy-lang.blogspot.com/2026/05/mypy-20-relased.html#:~:text=Drop Support for Targeting Python 3.9https://mypy-lang.blogspot.com/2026/05/mypy-20-relased.html#:~:text=Drop%20Support%20for%20Targeting%20Python%203.9
#15708https://github.com/python/typeshed/pull/15708
Avasamhttps://github.com/Avasam
completedhttps://github.com/python/typeshed/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on May 18, 2026https://github.com/python/typeshed/issues/10428#event-25667555742
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/10428
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/10428
stubs: false positiveType checkers report false errorshttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22stubs%3A%20false%20positive%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.