Title: Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported · Issue #22176 · python/mypy · GitHub
Open Graph Title: Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported · Issue #22176 · python/mypy
X Title: Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported · Issue #22176 · python/mypy
Description: Bug Report mypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is empty (class C[T: ()]). mypy 2.1.0, 2.2.0 and 2.3.0 all report Type variable must have at least two constrained types [misc] on that ...
Open Graph Description: Bug Report mypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is empty (class C[T: ()]). mypy 2.1.0, 2.2.0 and 2.3.0 all report Type variable must have at lea...
X Description: Bug Report mypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is empty (class C[T: ()]). mypy 2.1.0, 2.2.0 and 2.3.0 all report Type variable must have at lea...
Opengraph URL: https://github.com/python/mypy/issues/22176
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported","articleBody":"**Bug Report**\n\nmypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is **empty** (`class C[T: ()]`). mypy 2.1.0, 2.2.0 and 2.3.0 all report `Type variable must have at least two constrained types [misc]` on that line. The one-element case `T: (str,)` and the legacy `TypeVar(\"T\", str)` are still reported in 2.4.0, so only the empty-tuple path regressed.\n\n**To Reproduce**\n\n```python\nclass ClassK[T: ()]: # expected: error: Type variable must have at least two constrained types [misc]\n ...\n\nclass ClassL[T: (str,)]: # still reported in 2.4.0\n ...\n```\n\n```\n$ mypy --python-version 3.12 repro.py\n```\n\n**Expected Behavior**\n\nAn error on the `ClassK` line, as in mypy ≤ 2.3.0. CPython itself rejects the declaration at runtime (`TypeError: A single constraint is not allowed` / empty constraints), and pyright 1.1.414, pyrefly 1.3.2, ty 0.0.86 and zuban 0.10.0 all report it.\n\n**Actual Behavior**\n\nmypy 2.4.0:\n```\nrepro.py:4: error: Type variable must have at least two constrained types [misc]\nFound 1 error in 1 file (checked 1 source file)\n```\n(only `ClassL`; `ClassK` on line 1 is silently accepted)\n\nmypy 2.3.0:\n```\nrepro.py:1: error: Type variable must have at least two constrained types [misc]\nrepro.py:4: error: Type variable must have at least two constrained types [misc]\nFound 2 errors in 1 file (checked 1 source file)\n```\n\nThis also flips the typing conformance test `generics_syntax_declarations.py` (line 60, `class ClassK[T: ()]: # E`) from automated Pass (mypy 2.1.0, as in the published results) to Fail with 2.4.0.\n\n**Your Environment**\n\n- Mypy version used: 2.4.0 (compiled: yes); compared against 2.1.0 / 2.2.0 / 2.3.0 in separate venvs\n- Mypy command-line flags: `--python-version 3.12` (also reproduces with no flags)\n- Mypy configuration options from `mypy.ini` (and other config files): none\n- Python version used: 3.12.15, macOS arm64\n","author":{"url":"https://github.com/seunghyun-24","@type":"Person","name":"seunghyun-24"},"datePublished":"2026-10-11T01:50:52Z","url":"https://github.com/python/mypy/issues/22176"}
| 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:2b1e5304-a9dc-7218-4b24-08eb058bda28 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1E8:1EF2:8BB662:C23C5C:6B002571 |
| html-safe-nonce | ce232cb3cf82d9ba95e12251efed5255765a497ba88951a9b3bbc40627222952 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUU4OjFFRjI6OEJCNjYyOkMyM0M1Qzo2QjAwMjU3MSIsInZpc2l0b3JfaWQiOiI2NTA3ODU2NzgyMjQ3ODYzNjY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d7e2070d146a0f798e5d275979e8cee71ede47b78929775dc01258058e253080 |
| hovercard-subject-tag | issue:5797079164 |
| 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/22176/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1113dfa5f702e4bdb530a32158b01a2198b1ad78ae8643cab9f205daa9c5aba2/python/mypy/issues/22176 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1113dfa5f702e4bdb530a32158b01a2198b1ad78ae8643cab9f205daa9c5aba2/python/mypy/issues/22176 |
| og:image:alt | Bug Report mypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is empty (class C[T: ()]). mypy 2.1.0, 2.2.0 and 2.3.0 all report Type variable must have at lea... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | seunghyun-24 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width