Title: Possible bug: `*tuple[int, *tuple[Any, ...]]` is not treated as unbounded like `*tuple[*tuple[Any, ...]]` is (and `*tuple[Any, ...]` by itself) (passes pyright 1.1.414 , pyrefly 1.3.1) · Issue #22018 · python/mypy · GitHub
Open Graph Title: Possible bug: `*tuple[int, *tuple[Any, ...]]` is not treated as unbounded like `*tuple[*tuple[Any, ...]]` is (and `*tuple[Any, ...]` by itself) (passes pyright 1.1.414 , pyrefly 1.3.1) · Issue #22018 · python/mypy
X Title: Possible bug: `*tuple[int, *tuple[Any, ...]]` is not treated as unbounded like `*tuple[*tuple[Any, ...]]` is (and `*tuple[Any, ...]` by itself) (passes pyright 1.1.414 , pyrefly 1.3.1) · Issue #22018 · python/mypy
Description: Hello MyPy team! I am seeing error: Tuple index out of range [misc] in a case where it seems inappropriate (and it passes pyright 1.1.414 , pyrefly 1.3.1), where MyPy appears to be handling unpacked unbounded type tuples inconsistently: ...
Open Graph Description: Hello MyPy team! I am seeing error: Tuple index out of range [misc] in a case where it seems inappropriate (and it passes pyright 1.1.414 , pyrefly 1.3.1), where MyPy appears to be handling unpacke...
X Description: Hello MyPy team! I am seeing error: Tuple index out of range [misc] in a case where it seems inappropriate (and it passes pyright 1.1.414 , pyrefly 1.3.1), where MyPy appears to be handling unpacke...
Opengraph URL: https://github.com/python/mypy/issues/22018
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Possible bug: `*tuple[int, *tuple[Any, ...]]` is not treated as unbounded like `*tuple[*tuple[Any, ...]]` is (and `*tuple[Any, ...]` by itself) (passes pyright 1.1.414 , pyrefly 1.3.1)","articleBody":"Hello MyPy team!\n\nI am seeing `error: Tuple index out of range [misc]` in a case where it seems inappropriate (and it passes pyright 1.1.414 , pyrefly 1.3.1), where MyPy appears to be handling unpacked unbounded type tuples inconsistently:\n`*tuple[int, *tuple[Any, ...]]` is not treated as unbounded like `*tuple[*tuple[Any, ...]]` is (and `*tuple[Any, ...]` by itself).\n\nIn the following example (try it online in the MyPy Playground at https://mypy-play.net/?gist=0ce2970c7a6472603d696e130beeabcc ), \n`f` and `f2` pass, but `f3` fails MyPy with `error: Tuple index out of range [misc]`:\n```\n# e.g. python 3.12, mypy 2.3.1\n# passes pyright 1.1.414 , pyrefly 1.3.1 \nfrom typing import Any\n\n# see https://peps.python.org/pep-0646/#unpacking-unbounded-tuple-types#:~:text=Note%20that%20Tuple\n# this one is handled properly\ndef f(*args: *tuple[*tuple[Any, ...]]) -> None:\n reveal_type(args[0]) # Any\n reveal_type(args[1]) # Any\n \n# this is also handled properly\ndef f2(*args: *tuple[int, *tuple[Any, int]]) -> None:\n reveal_type(args[1]) # Any\n \n\n# but *args is not recognized as unbounded here?\n# there seems to be general support for such forms for some kinds of type matching recognizing the unboundedness, see e.g. the example at https://web.archive.org/web/20260918002706/https://typing.python.org/en/latest/spec/generics.html#:~:text=type%20and%20a%20part%20of%20an%20arbitrary-length%20tuple \ndef f3(*args: *tuple[int, *tuple[Any, ...]]) -> None:\n reveal_type(args[1]) # error: `Tuple index out of range [misc]`, seems it should be recognized as unbounded like in f, why is this considered ambiguous?\n```\n\nThanks in advance! \n\nIt is also fine just to confirm the expected behavior without promising any fix, I would be happy to write test cases and attempt a fix myself. I am trying to understand the intended behavior here in part to evaluate solutions to https://github.com/python/mypy/issues/21998 (my own and potentially others, e.g. see below).\n\ncc/ @00200200 as the intended behavior here would affect their PR at https://github.com/python/mypy/pull/22002 .","author":{"url":"https://github.com/willy-b","@type":"Person","name":"willy-b"},"datePublished":"2026-09-21T18:02:02Z","url":"https://github.com/python/mypy/issues/22018"}
| 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:081270c2-01cb-5607-d4e0-e70b42db9c15 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D164:308D9D:21278A8:2D2430D:6B0023A4 |
| html-safe-nonce | e4b85047236c1017b4c0dcc7abcb8e511a85b29028ecff2abd1365b5903b5bd8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTY0OjMwOEQ5RDoyMTI3OEE4OjJEMjQzMEQ6NkIwMDIzQTQiLCJ2aXNpdG9yX2lkIjoiMzYzNDg2MjUyOTg0ODU1MDMwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f5f359379c414deae5452f6320fd1c8b53e59c1773dfa970a954ec6d4ccbf90c |
| hovercard-subject-tag | issue:5530648706 |
| 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/22018/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9a7945a0a9d9374914d12f2d0cba67e9b68d6724ad21d9ff68761ee09104c0e7/python/mypy/issues/22018 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9a7945a0a9d9374914d12f2d0cba67e9b68d6724ad21d9ff68761ee09104c0e7/python/mypy/issues/22018 |
| og:image:alt | Hello MyPy team! I am seeing error: Tuple index out of range [misc] in a case where it seems inappropriate (and it passes pyright 1.1.414 , pyrefly 1.3.1), where MyPy appears to be handling unpacke... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | willy-b |
| 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