René's URL Explorer Experiment


Title: [1.16 regression] no longer recognizes enum singleton as only possible case · Issue #19271 · python/mypy · GitHub

Open Graph Title: [1.16 regression] no longer recognizes enum singleton as only possible case · Issue #19271 · python/mypy

X Title: [1.16 regression] no longer recognizes enum singleton as only possible case · Issue #19271 · python/mypy

Description: I have an enum class Raise that has a single member, Raise._. I use this as a pattern to indicate that a function argument, if not specified, will default to raising an exception. Essentially it serves as an alternative to None, which a ...

Open Graph Description: I have an enum class Raise that has a single member, Raise._. I use this as a pattern to indicate that a function argument, if not specified, will default to raising an exception. Essentially it se...

X Description: I have an enum class Raise that has a single member, Raise._. I use this as a pattern to indicate that a function argument, if not specified, will default to raising an exception. Essentially it se...

Opengraph URL: https://github.com/python/mypy/issues/19271

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[1.16 regression] no longer recognizes enum singleton as only possible case","articleBody":"I have an enum class `Raise` that has a single member, `Raise._`. I use this as a pattern to indicate that a function argument, if not specified, will default to raising an exception. Essentially it serves as an alternative to `None`, which a caller might want to explicitly pass. The following used to work in 1.15 but 1.16 complains.\n\n```\nfrom enum import Enum\nfrom os import environ\nfrom typing import final, TypeVar, Union\n\n\n@final # 1.16 fails with or without this.\nclass Raise(Enum):\n  '''\n  A singleton value to indicate that the default behavior is to raise an exception.\n  '''\n  _ = 0\n\n\ndef get_some_config_val(default:str|Raise=Raise._) -> str:\n  '''\n  Get some config value or return the default. If default is not specified,\n  then raise an exception.\n  '''\n  try:\n    return environ['SOME_CONFIG_VAL']\n  except KeyError:\n    if default is Raise._: raise\n    return default\n```\n\nIn 1.15 it appears that that mypy understood that `Raise._` was the only value of type `Raise`. In 1.16 that returns `error: Incompatible return value type (got \"str | Raise\", expected \"str\")  [return-value]`.\n\nNote that originally I did not have the `@final` decoration. After some reading I am unsure whether or not it should be required for this example to work, but it does not seem to affect the behavior of either 1.15 or 1.16. It would seem that the @final should be necessary for mypy to recognize that `Raise._` is the only possible value of type `Raise`, unless it was proving to itself that there is no subclass of `Raise`.\n\nObviously, I can change the implementation to `if is instance(Raise._, Raise): raise`, but there is an apparent loss of sophistication in 1.16 so I thought it was worth reporting.\n\n\n```\nPython 3.13.3\nmypy 1.16.0 (compiled: yes)\n```\n","author":{"url":"https://github.com/gwk","@type":"Person","name":"gwk"},"datePublished":"2025-06-10T16:01:38Z","url":"https://github.com/python/mypy/issues/19271"}

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:a58cabbc-8c7d-5d10-ba46-ec689867d1e7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA05E:CEC0A:2E3B2E7:3D252BA:6B002402
html-safe-nonce51978f8c447ebb8f086eb5e678cc9f9642a322e1a5ff7f3e4e78e9a0498a296e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDVFOkNFQzBBOjJFM0IyRTc6M0QyNTJCQTo2QjAwMjQwMiIsInZpc2l0b3JfaWQiOiIzNDk2NDc0NzEwNzI2NjgxNjAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf18ec9a23ec2bc36049d50394c623cf33b787774c7a6fd73646009b869a5a8f6
hovercard-subject-tagissue:3134140317
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/mypy/19271/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8c21a498e5481f7f0c85bec2044e2ef85461b59eb11c18b9bf91d91aedda5a1e/python/mypy/issues/19271
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8c21a498e5481f7f0c85bec2044e2ef85461b59eb11c18b9bf91d91aedda5a1e/python/mypy/issues/19271
og:image:altI have an enum class Raise that has a single member, Raise._. I use this as a pattern to indicate that a function argument, if not specified, will default to raising an exception. Essentially it se...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegwk
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
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
release44c658b24abf00491fb7ae5f56d42c9f38cbeab2
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/19271#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F19271
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%2Fmypy%2Fissues%2F19271
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%2Fmypy
Reloadhttps://github.com/python/mypy/issues/19271
Reloadhttps://github.com/python/mypy/issues/19271
Reloadhttps://github.com/python/mypy/issues/19271
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests546 (546)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/19271
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/19271
#19273https://github.com/python/mypy/pull/19273
[1.16 regression] no longer recognizes enum singleton as only possible casehttps://github.com/python/mypy/issues/19271#top
#19273https://github.com/python/mypy/pull/19273
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
topic-enumhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-enum%22
https://github.com/gwk
gwkhttps://github.com/gwk
on Jun 10, 2025https://github.com/python/mypy/issues/19271#issue-3134140317
@Finalhttps://github.com/Final
gwkhttps://github.com/gwk
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on Jun 10, 2025https://github.com/python/mypy/issues/19271#event-18078678330
brianschuberthttps://github.com/brianschubert
topic-enumhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-enum%22
on Jun 10, 2025https://github.com/python/mypy/issues/19271#event-18079039673
https://github.com/brianschubert
brianschuberthttps://github.com/brianschubert
on Jun 10, 2025https://github.com/python/mypy/issues/19271#issuecomment-2959914042
#18675https://github.com/python/mypy/pull/18675
@sobolevnhttps://github.com/sobolevn
hauntsaninjahttps://github.com/hauntsaninja
on Jun 10, 2025https://github.com/python/mypy/issues/19271#event-18080618722
https://github.com/sterliakov
sterliakovhttps://github.com/sterliakov
on Jun 10, 2025https://github.com/python/mypy/issues/19271#issuecomment-2960699474
https://github.com/A5rocks
A5rockshttps://github.com/A5rocks
on Jun 11, 2025https://github.com/python/mypy/issues/19271#issuecomment-2961098031
https://github.com/sterliakov
sterliakovhttps://github.com/sterliakov
on Jun 11, 2025https://github.com/python/mypy/issues/19271#issuecomment-2961101967
@A5rockshttps://github.com/A5rocks
hauntsaninjahttps://github.com/hauntsaninja
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#19273https://github.com/python/mypy/pull/19273
on Jun 11, 2025https://github.com/python/mypy/issues/19271#event-18086573345
hauntsaninjahttps://github.com/hauntsaninja
on Jun 11, 2025https://github.com/python/mypy/issues/19271#event-18086573361
Single underscore is not a sunder (#19273)https://github.com/python/mypy/commit/f20988875ad7e02844c53231829f404c4a26f70c
#19273https://github.com/python/mypy/pull/19273
f209888https://github.com/python/mypy/commit/f20988875ad7e02844c53231829f404c4a26f70c
JukkaLhttps://github.com/JukkaL
on Jun 11, 2025https://github.com/python/mypy/issues/19271#event-18094152147
Single underscore is not a sunder (#19273)https://github.com/python/mypy/commit/e253eded9c887630f3f5404c4b9f73f13570476a
#19273https://github.com/python/mypy/pull/19273
e253edehttps://github.com/python/mypy/commit/e253eded9c887630f3f5404c4b9f73f13570476a
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/19271
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/19271
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
topic-enumhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-enum%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.