Title: Introduce a type for an unknown invariant generic param that behaves strictly · Issue #2169 · python/typing · GitHub
Open Graph Title: Introduce a type for an unknown invariant generic param that behaves strictly · Issue #2169 · python/typing
X Title: Introduce a type for an unknown invariant generic param that behaves strictly · Issue #2169 · python/typing
Description: This is the same issue as #1835, which was closed -- the given reason was that object can be used instead of Unknown. However, this is not the case. Consider: class Foo(tp.Generic[T]): def bar(self, x: T) -> T: ... def baz(...): ... I wa...
Open Graph Description: This is the same issue as #1835, which was closed -- the given reason was that object can be used instead of Unknown. However, this is not the case. Consider: class Foo(tp.Generic[T]): def bar(self...
X Description: This is the same issue as #1835, which was closed -- the given reason was that object can be used instead of Unknown. However, this is not the case. Consider: class Foo(tp.Generic[T]): def bar(self...
Opengraph URL: https://github.com/python/typing/issues/2169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Introduce a type for an unknown invariant generic param that behaves strictly","articleBody":"This is the same issue as #1835, which was closed -- the given reason was that `object` can be used instead of `Unknown`. However, this is not the case. Consider:\n\n```\nclass Foo(tp.Generic[T]):\n def bar(self, x: T) -> T:\n ...\n\n def baz(...):\n ...\n```\n\nI want a type that represents \"Foo with unknown T\", which I can call baz on but not bar.\n```\nfoo: Foo[Unknown] = ...\nfoo.bar(1) # type error, int cannot be assigned to Unknown\nfoo.baz() # works fine because no T is needed\n```\nThis doesn't work if I use object:\n```\nfoo: Foo[object] = ...\nfoo.bar(1) # typechecks because int is a subtype of object\n```","author":{"url":"https://github.com/vladfi1","@type":"Person","name":"vladfi1"},"datePublished":"2026-02-06T19:01:44Z","url":"https://github.com/python/typing/issues/2169"}
| 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:ec8ebfec-7494-775f-41c0-388bf590e1e7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C38E:C814F:EB52D9:1252BDD:6AFF80F7 |
| html-safe-nonce | a528756b872f79e74beaffeaf953377c660c63ff3fc2841ac5812cf241e08b56 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzhFOkM4MTRGOkVCNTJEOToxMjUyQkREOjZBRkY4MEY3IiwidmlzaXRvcl9pZCI6IjgyMDA1MDI5NDI2Mjk4NTU0NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 61cd185af36189c5fb07a972b4a14a0970638ec1754392160b184393aa560c09 |
| hovercard-subject-tag | issue:3908048435 |
| 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/2169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/045b56384a83c8d3b673635366c9bb89e52af6301b026fb0b383d48aa8d85cd1/python/typing/issues/2169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/045b56384a83c8d3b673635366c9bb89e52af6301b026fb0b383d48aa8d85cd1/python/typing/issues/2169 |
| og:image:alt | This is the same issue as #1835, which was closed -- the given reason was that object can be used instead of Unknown. However, this is not the case. Consider: class Foo(tp.Generic[T]): def bar(self... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vladfi1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19488db4031f00b04ea79b4c70b5dd32cfa873a8d20b3877f3896b8e2d195946 |
| 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 | 7952f5285f4ba685d70c4c7540ad3cc9dc9746b8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width