Title: Non-overlapping identity check error for typing.get_origin · Issue #10405 · python/typeshed · GitHub
Open Graph Title: Non-overlapping identity check error for typing.get_origin · Issue #10405 · python/typeshed
X Title: Non-overlapping identity check error for typing.get_origin · Issue #10405 · python/typeshed
Description: The following example produces an error in mypy --strict mode: import typing TypeSpec = typing.Any def is_union(spec: TypeSpec) -> bool: return typing.get_origin(spec) is typing.Union (it does work without the type alias). This gives: $ ...
Open Graph Description: The following example produces an error in mypy --strict mode: import typing TypeSpec = typing.Any def is_union(spec: TypeSpec) -> bool: return typing.get_origin(spec) is typing.Union (it does work...
X Description: The following example produces an error in mypy --strict mode: import typing TypeSpec = typing.Any def is_union(spec: TypeSpec) -> bool: return typing.get_origin(spec) is typing.Union (it does w...
Opengraph URL: https://github.com/python/typeshed/issues/10405
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Non-overlapping identity check error for typing.get_origin","articleBody":"The following example produces an error in mypy --strict mode:\r\n```python\r\nimport typing\r\n\r\nTypeSpec = typing.Any\r\n\r\ndef is_union(spec: TypeSpec) -> bool:\r\n return typing.get_origin(spec) is typing.Union\r\n```\r\n(it does work without the type alias).\r\nThis gives:\r\n```\r\n$ mypy --strict t.py\r\nt.py:6: error: Non-overlapping identity check (left operand type: \"type\", right operand type: \"\u003ctyping special form>\") [comparison-overlap]\r\n```\r\nIt looks like get_origin() is declared to return `type`, but it can actually return some other things, notably `Union` and `Literal`.\r\n\r\nmypy versions 1.4.1.","author":{"url":"https://github.com/eltoder","@type":"Person","name":"eltoder"},"datePublished":"2023-07-05T02:38:33Z","url":"https://github.com/python/typeshed/issues/10405"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5df82e85-7ba7-e61a-fc1c-b1e32029468a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D946:390AA2:203DCF3:2BD4AF0:6B001BE9 |
| html-safe-nonce | 8bcedb0d228f4d3af9b4d4d07a8de3378e9009b186945875e2c68741c5789a88 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTQ2OjM5MEFBMjoyMDNEQ0YzOjJCRDRBRjA6NkIwMDFCRTkiLCJ2aXNpdG9yX2lkIjoiMzAxNDc4NDA5OTczMTY0MzM2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d74aa30e0430fd8ba2e6769204f1a9a3304ca09f0148d0438ccc62ccbfa54234 |
| hovercard-subject-tag | issue:1788665656 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/10405/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9230a432d83e9db6f82baaa5571d584118b4c98552430fc2d12ac6e7262cc9b1/python/typeshed/issues/10405 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9230a432d83e9db6f82baaa5571d584118b4c98552430fc2d12ac6e7262cc9b1/python/typeshed/issues/10405 |
| og:image:alt | The following example produces an error in mypy --strict mode: import typing TypeSpec = typing.Any def is_union(spec: TypeSpec) -> bool: return typing.get_origin(spec) is typing.Union (it does work... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eltoder |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width