Title: Generic default type in `type` revealed as `Any` · Issue #21608 · python/mypy · GitHub
Open Graph Title: Generic default type in `type` revealed as `Any` · Issue #21608 · python/mypy
X Title: Generic default type in `type` revealed as `Any` · Issue #21608 · python/mypy
Description: Bug Report mypy reveals a certain nested default generic type in type as Any, while other type checkers reveal it as the default type. This issue is motivated by pandas-dev/pandas-stubs#1764. To Reproduce This is complicated, see #21608 ...
Open Graph Description: Bug Report mypy reveals a certain nested default generic type in type as Any, while other type checkers reveal it as the default type. This issue is motivated by pandas-dev/pandas-stubs#1764. To Re...
X Description: Bug Report mypy reveals a certain nested default generic type in type as Any, while other type checkers reveal it as the default type. This issue is motivated by pandas-dev/pandas-stubs#1764. To Re...
Opengraph URL: https://github.com/python/mypy/issues/21608
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic default type in `type` revealed as `Any`","articleBody":"\u003c!--\nIf you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form instead.\nPlease consider:\n\n- checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html\n- searching our issue tracker: https://github.com/python/mypy/issues to see if it's already been reported\n- asking on gitter chat: https://gitter.im/python/typing\n-->\n\n**Bug Report**\n\n`mypy` reveals a certain ~~nested~~ default generic type in `type` as `Any`, while other type checkers reveal it as the default type.\n\nThis issue is motivated by pandas-dev/pandas-stubs#1764.\n\n**To Reproduce**\n\nThis is complicated, see https://github.com/python/mypy/issues/21608#issuecomment-4692751812 for a much simplified example.\n\n```python\nfrom typing import Any, Generic, TypeVar, reveal_type\n\n_ItemT_co = TypeVar(\"_ItemT_co\", default=Any, covariant=True)\n\nclass generic(Generic[_ItemT_co]): ...\n\n_ScalarT_co = TypeVar(\"_ScalarT_co\", bound=generic, default=Any, covariant=True)\n\nclass dtype(Generic[_ScalarT_co]): ...\n\n_DT64ItemT_co = TypeVar(\n \"_DT64ItemT_co\", bound=int | None, default=int | None, covariant=True\n)\n\nclass datetime64(generic[_DT64ItemT_co], Generic[_DT64ItemT_co]): ...\n\nGenericT_co = TypeVar(\"GenericT_co\", bound=generic, default=Any, covariant=True)\nGenericT = TypeVar(\"GenericT\", bound=generic, default=Any)\n\nclass Series(Generic[GenericT_co]):\n def to_numpy_simplified(\n self, dtype: dtype[GenericT] | type[GenericT]\n ) -> GenericT: ...\n\nreveal_type(Series().to_numpy_simplified(datetime64)) # mypy: datetime64[Any], pyright & pyright: datetime64[int | None]\n```\n- https://gist.github.com/mypy-play/099705d9f12556f66776949caa6f0450\n- https://pyright-play.net/?strict=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMoCCKcANFAOICmKlISAxmQCqKUBqAhiGSJQG6UOAGwD68BJQCwAKBkiAkjEoQmI%2BmCgBeKCwmcQACgBECpSrVgjZACaVgHAK5CYmoqSjq%2BXJBxQumIA6UAJQyMvRCHADOUVBo1LQMBlQ0dPQA2qbKquoAusEAXFAAdKVh0iIAyvTCXDka2rrsXMZVNZEg9VZQAEZgDijWmvGpDDZ2js6uxGSe3r7%2BgSHlEdGx1uKUyQlpmdW1nRb5RaXF5SIAIkwAbAAsitkWWjqs%2BgYyUJ9QJld3D%2Bbqbp9AZDVD4AA%2BUAAcmAaON7E4XGCoJCYXCPGAvHQFpoAkEZKFZNJVjEoNYOEoYFhKHcDCNEhlLjd7mZ6rkyCkGZlfizHnlCiUykTOWl6s8mm8jCKGF0yMDBsMdmMyRNEdN3HNsX5cUtCdL6Exxa8WlKlQagf0FfS0vDJi43ITwpFSZVEpQottRhl9WzCh8vrZgLAwCIUA5sHARFEsAghEhgEhKNZ3tIvmmoFFKEJgDZNkUNqx0j7cijYIXi-7PsEoABaAB8FDNTBOQpkvAEwjErAMrro7oMwWKMBDYYjUZjcYTSYM5Mp1LuwUJQA\n- https://play.ty.dev/8c070d59-a962-4cd0-823f-fa8dd9941f4f\n\n**Expected Behavior**\n\n`datetime64[int | None]`\n\n**Actual Behavior**\n\n`datetime64[Any]`","author":{"url":"https://github.com/cmp0xff","@type":"Person","name":"cmp0xff"},"datePublished":"2026-06-12T15:31:35Z","url":"https://github.com/python/mypy/issues/21608"}
| 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:5dc21e5d-bbce-03db-bb9f-b2d7586b7779 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C08E:43251:173A5BA:1EE9BC4:6B002AA4 |
| html-safe-nonce | 9f0b1c91b66d50e35c00081959177c06ee84ce1494fb06e6da2b40d66dfbfb29 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDhFOjQzMjUxOjE3M0E1QkE6MUVFOUJDNDo2QjAwMkFBNCIsInZpc2l0b3JfaWQiOiIyNTE3MjAxMTA3OTkwNzE5MDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 97ac099ded7d8b1349aa525bd2a10f5803419c1df9be1d4f6fb9aab370a472c8 |
| hovercard-subject-tag | issue:4650512799 |
| 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/21608/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9b692cec6306b8118a2ddbeb6e61837092aa931ac4456b7134ebaa0d9bfec521/python/mypy/issues/21608 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9b692cec6306b8118a2ddbeb6e61837092aa931ac4456b7134ebaa0d9bfec521/python/mypy/issues/21608 |
| og:image:alt | Bug Report mypy reveals a certain nested default generic type in type as Any, while other type checkers reveal it as the default type. This issue is motivated by pandas-dev/pandas-stubs#1764. To Re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cmp0xff |
| 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