Title: `generics_defaults.py` mandates that type checkers should allow a class that raises `TypeError` at runtime · Issue #2211 · python/typing · GitHub
Open Graph Title: `generics_defaults.py` mandates that type checkers should allow a class that raises `TypeError` at runtime · Issue #2211 · python/typing
X Title: `generics_defaults.py` mandates that type checkers should allow a class that raises `TypeError` at runtime · Issue #2211 · python/typing
Description: This test mandates that type checkers should allow classes that have ParamSpecs-with-defaults following TypeVarTuples: typing/conformance/tests/generics_defaults.py Lines 191 to 200 in 22d9392 # > It is allowed to have a ``ParamSpec`` wi...
Open Graph Description: This test mandates that type checkers should allow classes that have ParamSpecs-with-defaults following TypeVarTuples: typing/conformance/tests/generics_defaults.py Lines 191 to 200 in 22d9392 # > ...
X Description: This test mandates that type checkers should allow classes that have ParamSpecs-with-defaults following TypeVarTuples: typing/conformance/tests/generics_defaults.py Lines 191 to 200 in 22d9392 # &g...
Opengraph URL: https://github.com/python/typing/issues/2211
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`generics_defaults.py` mandates that type checkers should allow a class that raises `TypeError` at runtime","articleBody":"This test mandates that type checkers should allow classes that have `ParamSpec`s-with-defaults following `TypeVarTuple`s: https://github.com/python/typing/blob/22d9392a5ead302cc02c47ecbbcf3aa40106fd9f/conformance/tests/generics_defaults.py#L191-L200\n\nBut these fail at runtime. Using Python 3.11 syntax:\n\n```pytb\n% uvx python3.14 \nPython 3.14.0 (main, Oct 10 2025, 12:54:13) [Clang 20.1.4 ] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> from typing import *\n>>> Ts = TypeVarTuple(\"Ts\")\n>>> P = ParamSpec(\"P\", default=[int, str])\n>>> class A(Generic[*Ts, P]): ...\n... \nTraceback (most recent call last):\n File \"\u003cpython-input-3>\", line 1, in \u003cmodule>\n class A(Generic[*Ts, P]): ...\n ~~~~~~~^^^^^^^^\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 402, in inner\n return func(*args, **kwds)\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 1157, in _generic_class_getitem\n return _GenericAlias(cls, args)\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 1334, in __init__\n self.__parameters__ = _collect_type_parameters(\n ~~~~~~~~~~~~~~~~~~~~~~~~^\n args,\n ^^^^^\n enforce_default_ordering=enforce_default_ordering,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 291, in _collect_type_parameters\n raise TypeError('Type parameter with a default'\n ' follows TypeVarTuple')\nTypeError: Type parameter with a default follows TypeVarTuple\n```\n\nUsing Python \u003c=3.10 syntax:\n\n```pytb\n>>> class B(Generic[Unpack[Ts], P]): ...\n... \nTraceback (most recent call last):\n File \"\u003cpython-input-4>\", line 1, in \u003cmodule>\n class B(Generic[Unpack[Ts], P]): ...\n ~~~~~~~^^^^^^^^^^^^^^^\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 402, in inner\n return func(*args, **kwds)\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 1157, in _generic_class_getitem\n return _GenericAlias(cls, args)\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 1334, in __init__\n self.__parameters__ = _collect_type_parameters(\n ~~~~~~~~~~~~~~~~~~~~~~~~^\n args,\n ^^^^^\n enforce_default_ordering=enforce_default_ordering,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 291, in _collect_type_parameters\n raise TypeError('Type parameter with a default'\n ' follows TypeVarTuple')\nTypeError: Type parameter with a default follows TypeVarTuple\n```\n\nAnd using Python 3.13+ syntax:\n\n```pytb\n>>> class C[*Ts, **P = [int, str]]: ...\n... \nTraceback (most recent call last):\n File \"\u003cpython-input-5>\", line 1, in \u003cmodule>\n class C[*Ts, **P = [int, str]]: ...\n File \"\u003cpython-input-5>\", line 1, in \u003cgeneric parameters of C>\n class C[*Ts, **P = [int, str]]: ...\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 1334, in __init__\n self.__parameters__ = _collect_type_parameters(\n ~~~~~~~~~~~~~~~~~~~~~~~~^\n args,\n ^^^^^\n enforce_default_ordering=enforce_default_ordering,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/alexw/Library/Application Support/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/typing.py\", line 291, in _collect_type_parameters\n raise TypeError('Type parameter with a default'\n ' follows TypeVarTuple')\nTypeError: Type parameter with a default follows TypeVarTuple\n```\n\nSince it seems that the tests are quoting the spec here, is this a bug in the runtime implementation of the typing module? Or should we update the spec and the conformance suite to allow type checkers to catch this runtime error?","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2026-03-08T16:53:27Z","url":"https://github.com/python/typing/issues/2211"}
| 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:0a91d083-3ade-d55f-598f-851f669ae0d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A3E:3E8A12:24A607:2F1A35:6AFF8614 |
| html-safe-nonce | f3bccf7a77e417075fc4864f6f83472bf6ff9af7b04c854b33da6c5a9a8a95e6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTNFOjNFOEExMjoyNEE2MDc6MkYxQTM1OjZBRkY4NjE0IiwidmlzaXRvcl9pZCI6Ijg1MzA2OTk0NzQyOTU1NTU2MDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1b10cff2d95ef4802498d96a9a0d2fc6e7ee4c0945f4fcb427414402e615aaad |
| hovercard-subject-tag | issue:4041698498 |
| 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/typing/2211/issue_layout |
| twitter:image | https://opengraph.githubassets.com/85700ed6297f70af0a38c32f4c856627402da32c378ea82bf06e0eb9b3cfa84c/python/typing/issues/2211 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/85700ed6297f70af0a38c32f4c856627402da32c378ea82bf06e0eb9b3cfa84c/python/typing/issues/2211 |
| og:image:alt | This test mandates that type checkers should allow classes that have ParamSpecs-with-defaults following TypeVarTuples: typing/conformance/tests/generics_defaults.py Lines 191 to 200 in 22d9392 # > ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexWaygood |
| hostname | github.com |
| expected-hostname | github.com |
| None | 587ad99a3e443b2e1cb0d3df059ec49ab54389861f13310766dfdeb615fed90d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typing git https://github.com/python/typing.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 24604008 |
| octolytics-dimension-repository_nwo | python/typing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24604008 |
| octolytics-dimension-repository_network_root_nwo | python/typing |
| 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 | 5bb0fb68d64881d1344f5863d809515d496801e5 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width