René's URL Explorer Experiment


Title: Introduce a Not type · Issue #801 · python/typing · GitHub

Open Graph Title: Introduce a Not type · Issue #801 · python/typing

X Title: Introduce a Not type · Issue #801 · python/typing

Description: This is a continuation of this discussion on the Intersection issue. I have a different use case for the Not[...] type, but it is related to the original discussion. My usecase is to be able to tell the type checker that two types can ne...

Open Graph Description: This is a continuation of this discussion on the Intersection issue. I have a different use case for the Not[...] type, but it is related to the original discussion. My usecase is to be able to tel...

X Description: This is a continuation of this discussion on the Intersection issue. I have a different use case for the Not[...] type, but it is related to the original discussion. My usecase is to be able to tel...

Opengraph URL: https://github.com/python/typing/issues/801

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Introduce a Not type","articleBody":"This is a continuation of this [discussion on the Intersection issue](https://github.com/python/typing/issues/213#issuecomment-344132917).\r\n\r\nI have a different use case for the `Not[...]` type, but it is related to the original discussion. My usecase is to be able to tell the type checker that two types can never have an intersection. The specific case is for the [phantom-types](https://github.com/antonagestam/phantom-types/blob/main/phantom/sized.py#L80) library where there are two types `NonEmpty` and `Empty`.\r\n\r\nCurrently there is no way to tell mypy that a variable can't both be `NonEmpty` and `Empty`, so this code passes without error:\r\n\r\n```python\r\nfrom __future__ import annotations\r\nfrom phantom.sized import NonEmpty, Empty\r\n\r\ni: tuple[int, ...] = ()\r\n\r\nassert isinstance(i, Empty)\r\nassert isinstance(i, NonEmpty)\r\n\r\nreveal_type(i)\r\n```\r\n\r\nThe output shows that mypy interprets `i` as an intersection between `tuple`, `Empty` and `NonEmpty`:\r\n\r\n```\r\nintx.py:9: note: Revealed type is 'intx.\u003csubclass of \"tuple\", \"Empty\", and \"NonEmpty\">'\r\n```\r\n\r\nOf course this code would error at runtime, but it would be preferable if this could be expressible so that type checkers can give an error here, similarly to how mypy gives errors for unreachable code.\r\n\r\nA suggestion for how this could be expressed is to allow subclassing a `Not` type, so simplified the definitions of the two mentioned types would like this:\r\n\r\n```python\r\nclass NonEmpty:\r\n    ...\r\n\r\nclass Empty(Not[NonEmpty]):\r\n    ...\r\n```\r\n\r\nThere are also other types in the library that would benefit from this like [`TZAware` and `TZNaive`](https://github.com/antonagestam/phantom-types/blob/main/phantom/datetime.py).\r\n\r\n**Edit**: To clarify, I think that this type would be valuable even without an `Intersection` type which is why I opened a separate issue. This is because (as showed in the example) there already _implicit_ intersections in mypy. I don't know how the other type checkers treats this.","author":{"url":"https://github.com/antonagestam","@type":"Person","name":"antonagestam"},"datePublished":"2021-04-22T08:09:41Z","url":"https://github.com/python/typing/issues/801"}

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:6a71d6df-7f5b-e02c-1064-cfd1570128b8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB0EA:D064:2243A3A:2E853C5:6B002518
html-safe-nonce7d0795b91c7947cee9402abd3066399a43758ce6b4ef05313f24822fb57f6bdc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEVBOkQwNjQ6MjI0M0EzQToyRTg1M0M1OjZCMDAyNTE4IiwidmlzaXRvcl9pZCI6Ijg4NjQwOTM2NjQ5NDc3NDE5NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2d3dd58119f817cf1b098b3064c265173e9affebbedea4a2a531f67b8f264b7e
hovercard-subject-tagissue:864669499
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/typing/801/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6091db1c2818caabab5344853c39b99acc0720b8fd586c085ecbce5360cb0a5f/python/typing/issues/801
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6091db1c2818caabab5344853c39b99acc0720b8fd586c085ecbce5360cb0a5f/python/typing/issues/801
og:image:altThis is a continuation of this discussion on the Intersection issue. I have a different use case for the Not[...] type, but it is related to the original discussion. My usecase is to be able to tel...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameantonagestam
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
turbo-cache-controlno-preview
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
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/typing/issues/801#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F801
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%2Ftyping%2Fissues%2F801
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%2Ftyping
Reloadhttps://github.com/python/typing/issues/801
Reloadhttps://github.com/python/typing/issues/801
Reloadhttps://github.com/python/typing/issues/801
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
https://github.com/python/typing
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/801
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/801
Introduce a Not typehttps://github.com/python/typing/issues/801#top
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
https://github.com/antonagestam
antonagestamhttps://github.com/antonagestam
on Apr 22, 2021https://github.com/python/typing/issues/801#issue-864669499
discussion on the Intersection issuehttps://github.com/python/typing/issues/213#issuecomment-344132917
phantom-typeshttps://github.com/antonagestam/phantom-types/blob/main/phantom/sized.py#L80
TZAware and TZNaivehttps://github.com/antonagestam/phantom-types/blob/main/phantom/datetime.py
srittauhttps://github.com/srittau
enhancementhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Oct 3, 2021https://github.com/python/typing/issues/801#event-5399541276
https://github.com/KotlinIsland
KotlinIslandhttps://github.com/KotlinIsland
on Oct 5, 2021https://github.com/python/typing/issues/801#issuecomment-935088151
srittauhttps://github.com/srittau
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
enhancementhttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Nov 4, 2021https://github.com/python/typing/issues/801#event-5568169818
https://github.com/mccolljr
mccolljrhttps://github.com/mccolljr
on Jan 3, 2022https://github.com/python/typing/issues/801#issuecomment-1003866919
https://github.com/harahu
harahuhttps://github.com/harahu
on Jun 16, 2022https://github.com/python/typing/issues/801#issuecomment-1157553198
https://github.com/ekalosak
ekalosakhttps://github.com/ekalosak
on Aug 4, 2022https://github.com/python/typing/issues/801#issuecomment-1205404860
https://mypy.readthedocs.io/en/stable/protocols.html#callback-protocolshttps://mypy.readthedocs.io/en/stable/protocols.html#callback-protocols
https://github.com/eyaler
eyalerhttps://github.com/eyaler
on Nov 16, 2022https://github.com/python/typing/issues/801#issuecomment-1316584841
Intersectionhttps://github.com/python/typing/issues/213
python/mypy#13893https://github.com/python/mypy/issues/13893
herehttps://github.com/python/mypy/issues/13893
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Nov 16, 2022https://github.com/python/typing/issues/801#issuecomment-1317152497
@eyalerhttps://github.com/eyaler
#1043https://github.com/python/typing/issues/1043
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Jan 9, 2023https://github.com/python/typing/issues/801#issuecomment-1376352463
#256https://github.com/python/typing/issues/256
#213https://github.com/python/typing/issues/213
https://github.com/spacether
spacetherhttps://github.com/spacether
on Jun 9, 2023https://github.com/python/typing/issues/801#issuecomment-1583963518
https://github.com/CarliJoy
CarliJoyhttps://github.com/CarliJoy
on Jul 11, 2023https://github.com/python/typing/issues/801#issuecomment-1630405350
to join the sprinthttps://ep2023.europython.eu/sprints#typing-peps
https://github.com/jessestricker
jessestrickerhttps://github.com/jessestricker
on Jul 13, 2023https://github.com/python/typing/issues/801#issuecomment-1634447388
#213https://github.com/python/typing/issues/213
set theoryhttps://mathworld.wolfram.com/ComplementSet.html
https://github.com/erictraut
erictrauthttps://github.com/erictraut
on Jul 13, 2023https://github.com/python/typing/issues/801#issuecomment-1634495993
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Jul 13, 2023https://github.com/python/typing/issues/801#issuecomment-1634507905
https://github.com/superbobry
superbobryhttps://github.com/superbobry
on Jul 13, 2023https://github.com/python/typing/issues/801#issuecomment-1634877226
@erictrauthttps://github.com/erictraut
https://github.com/erictraut
erictrauthttps://github.com/erictraut
on Jul 15, 2023https://github.com/python/typing/issues/801#issuecomment-1636814125
appendix Ahttps://peps.python.org/pep-0695/#appendix-a-survey-of-type-parameter-syntax
https://github.com/gandhis1
gandhis1https://github.com/gandhis1
on Jul 15, 2023https://github.com/python/typing/issues/801#issuecomment-1636825239
https://github.com/superbobry
superbobryhttps://github.com/superbobry
on Jul 15, 2023https://github.com/python/typing/issues/801#issuecomment-1636884835
need to spechttp://bit.ly/python-subtyping
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Jul 21, 2023https://github.com/python/typing/issues/801#issuecomment-1646171898
pyright playgroundhttps://pyright-play.net/?strict=true&reportUnreachable=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMpgBuApiADZgCGAJgDRQAySMplZ9TLIbAyjCKjT0AcsRIgAUBIDGZSgGd5UHqSTF5ALigA6XVIACRUhRoTqxYFAXwExABTUbxLZ1ZkA2gCJgJmAGYAJk96b18ANgAWYKhPVH8gkLjIzwBdAEooAFoAPmVVdS1dbQlDcRNqMwsreScHJxdmNz4BdAycqFFxQr1S4yoK80trRHtHEa0akDbclQECnT1KyxYagH00MDBqVbJGtjtpjrAUZwkoc6sQDABeGJ8qeM8zi5AxYjZV2sorjKgAYkYjW4HlCD0CqWe51eJA%2BXxqIzs3zQaV%2BANmankS1g6hgqwARjQdkD9odhMdThdLjcYnjNmQnpToe8yJ8EUjUYCuGwvLSwPSUpCoEzYWz4bZET8OZ1SFiVriNltVtQ4ChKBAkNIDllcmSThpBUioLdJnZQZRHmlBcKWV8fucAZMrW8ReLhq7Jfa8nNMYNsWsCdtlar1dJVpNBFr2rqKRdDcb%2BKbefTLYznTa2Xb-lBHamYenXWL7OyOej1BIgA
https://github.com/NeilGirdhar
NeilGirdharhttps://github.com/NeilGirdhar
on Aug 14, 2023https://github.com/python/typing/issues/801#issuecomment-1678081513
Constraining a TypeVar to be not None seems impossible. mypy#8881https://github.com/python/mypy/issues/8881
We need Not to properly express some parts of Intersections CarliJoy/intersection_examples#17https://github.com/CarliJoy/intersection_examples/issues/17
https://github.com/mikeshardmind
mikeshardmindhttps://github.com/mikeshardmind
on Aug 16, 2023https://github.com/python/typing/issues/801#issuecomment-1679883519
appendix Ahttps://peps.python.org/pep-0695/#appendix-a-survey-of-type-parameter-syntax
gradual typinghttps://www.irif.fr/~gc/papers/icfp17.pdf
https://private-user-images.githubusercontent.com/22035876/260883286-c7c89bf0-e4bd-47d7-923e-1cea4e3f423a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUxNzE5MDksIm5iZiI6MTc5NTE3MTYwOSwicGF0aCI6Ii8yMjAzNTg3Ni8yNjA4ODMyODYtYzdjODliZjAtZTRiZC00N2Q3LTkyM2UtMWNlYTRlM2Y0MjNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTIwVDEwNDY0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRiMjU1NWUyMDRmODg2OTk0MjZhYjcwYzY5NmIwMTQ5YTNlMDgyODk0MDg3ODkyMjIwZjVjYmViMjBmOWY2YzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.9vbqyDmAqUw15ilihxUpfCyQ3dGpCsQMtFD9m9WoYYw
https://github.com/Asaurus1
Asaurus1https://github.com/Asaurus1
on Sep 25, 2023https://github.com/python/typing/issues/801#issuecomment-1732995122
https://github.com/llucax
llucaxhttps://github.com/llucax
on Dec 4, 2024https://github.com/python/typing/issues/801#issuecomment-2516721191
https://github.com/flying-sheep
flying-sheephttps://github.com/flying-sheep
on May 30, 2025https://github.com/python/typing/issues/801#issuecomment-2922263875
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Jul 17, 2025https://github.com/python/typing/issues/801#issuecomment-3082529072
https://jellezijlstra.github.io/negation-typeshttps://jellezijlstra.github.io/negation-types
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
on Jul 17, 2025https://github.com/python/typing/issues/801#issuecomment-3083077513
1https://github.com/python/typing/issues/801#user-content-fn-1-f12f215616cbde0947ae3b2cc2330be3
my original commenthttps://github.com/python/typing/issues/801#issuecomment-1646171898
NoReturn and Never are underspecified in the spec #1458https://github.com/python/typing/issues/1458
↩https://github.com/python/typing/issues/801#user-content-fnref-1-f12f215616cbde0947ae3b2cc2330be3
https://github.com/mikeshardmind
mikeshardmindhttps://github.com/mikeshardmind
on Jul 17, 2025https://github.com/python/typing/issues/801#issuecomment-3083223201
https://github.com/erictraut
erictrauthttps://github.com/erictraut
on Jul 17, 2025https://github.com/python/typing/issues/801#issuecomment-3085226511
@JelleZijlstrahttps://github.com/JelleZijlstra
typescript issue trackerhttps://github.com/microsoft/TypeScript/issues/4196
rust-lang issue trackerhttps://github.com/rust-lang/rust/issues/42721
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Jul 18, 2025https://github.com/python/typing/issues/801#issuecomment-3086458404
@erictrauthttps://github.com/erictraut
@randolf-scholzhttps://github.com/randolf-scholz
@mikeshardmindhttps://github.com/mikeshardmind
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/801
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/801
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%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.