Title: PEP 604 unions don't work with generic type aliases · Issue #12211 · python/mypy · GitHub
Open Graph Title: PEP 604 unions don't work with generic type aliases · Issue #12211 · python/mypy
X Title: PEP 604 unions don't work with generic type aliases · Issue #12211 · python/mypy
Description: Bug Report Python 3.10 new Union syntax doesn't work in a scenario old syntax did when involved with generic type aliases. To Reproduce Create the following definitions: _ResponseType = TypeVar("_ResponseType") SyncFunc: TypeAlias = Call...
Open Graph Description: Bug Report Python 3.10 new Union syntax doesn't work in a scenario old syntax did when involved with generic type aliases. To Reproduce Create the following definitions: _ResponseType = TypeVar("_R...
X Description: Bug Report Python 3.10 new Union syntax doesn't work in a scenario old syntax did when involved with generic type aliases. To Reproduce Create the following definitions: _ResponseType = TypeVar...
Opengraph URL: https://github.com/python/mypy/issues/12211
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PEP 604 unions don't work with generic type aliases","articleBody":"**Bug Report**\r\n\r\nPython 3.10 new Union syntax doesn't work in a scenario old syntax did when involved with generic type aliases.\r\n\r\n**To Reproduce**\r\n\r\nCreate the following definitions:\r\n\r\n\r\n```\r\n_ResponseType = TypeVar(\"_ResponseType\")\r\n\r\n\r\nSyncFunc: TypeAlias = Callable[..., _ResponseType]\r\nCoro: TypeAlias = Callable[..., Coroutine[Any, Any, _ResponseType]]\r\n\r\nSyncFuncOrCoro: TypeAlias = Coro[_ResponseType] | SyncFunc[_ResponseType]\r\n\r\n```\r\n**Expected Behavior**\r\n\r\nShould work without errors, like it does when using old Union syntax:\r\n\r\n```\r\n_ResponseType = TypeVar(\"_ResponseType\")\r\n\r\n\r\nSyncFunc: TypeAlias = Callable[..., _ResponseType]\r\nCoro: TypeAlias = Callable[..., Coroutine[Any, Any, _ResponseType]]\r\n\r\nSyncFuncOrCoro: TypeAlias = Union[Coro[_ResponseType], SyncFunc[_ResponseType]]\r\n```\r\n\r\n**Actual Behavior**\r\n\r\nI receive mypy error \"Type application is only supported for generic classes\".\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.931\r\n- Mypy command-line flags: N/A\r\n- Python version used: 3.10.2\r\n- Operating system and version: Windows 11\r\n- Mypy configuration options from `mypy.ini` (and other config files):\r\n\r\nI'm using pretty strict mypy settings:\r\n\r\n[mypy]\r\nfollow_imports = normal\r\nignore_errors = false\r\nimplicit_reexport = false\r\nwarn_redundant_casts = True\r\nwarn_unused_ignores = True\r\ndisallow_any_generics = True\r\ndisallow_untyped_defs = True\r\ncheck_untyped_defs = True\r\nallow_redefinition = false\r\nlocal_partial_types = True\r\nstrict_optional = true\r\nstrict_equality = true\r\nwarn_unused_configs = true\r\nwarn_unreachable = true\r\nwarn_no_return = true\r\nno_implicit_optional = true\r\n","author":{"url":"https://github.com/Eldar1205","@type":"Person","name":"Eldar1205"},"datePublished":"2022-02-18T14:00:30Z","url":"https://github.com/python/mypy/issues/12211"}
| 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:cea12faf-c1bf-7e71-b8d9-4c11a409d4f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ACC4:3A13A0:24BF8B5:31E2EB1:6B00341E |
| html-safe-nonce | fa3590f3b0363bb7ac1ce750f71e6e8d79ecb3cb1c4ca3a528dbe9e81eba8f3e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0M0OjNBMTNBMDoyNEJGOEI1OjMxRTJFQjE6NkIwMDM0MUUiLCJ2aXNpdG9yX2lkIjoiODcwNTg2NjM3Mzk3ODQwMzg3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7485e276d6a38c66ef14ba095b4db11c03265f11097d0e468a6bd11b3a9bb343 |
| hovercard-subject-tag | issue:1143115875 |
| 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/mypy/12211/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55b64f7143336f4be436fc3af0f2a5396a1703496ac6531d53bcc2e7469da8a1/python/mypy/issues/12211 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55b64f7143336f4be436fc3af0f2a5396a1703496ac6531d53bcc2e7469da8a1/python/mypy/issues/12211 |
| og:image:alt | Bug Report Python 3.10 new Union syntax doesn't work in a scenario old syntax did when involved with generic type aliases. To Reproduce Create the following definitions: _ResponseType = TypeVar("_R... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Eldar1205 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width