Title: Should `collections.abc.Container` be generic? · Issue #15307 · python/typeshed · GitHub
Open Graph Title: Should `collections.abc.Container` be generic? · Issue #15307 · python/typeshed
X Title: Should `collections.abc.Container` be generic? · Issue #15307 · python/typeshed
Description: This is more of a question, but I am a bit confused about the current definition of Container. Right now, it looks like it is typeshed/stdlib/typing.pyi Lines 643 to 647 in a3568ac @runtime_checkable class Container(Protocol[_T_co]): # T...
Open Graph Description: This is more of a question, but I am a bit confused about the current definition of Container. Right now, it looks like it is typeshed/stdlib/typing.pyi Lines 643 to 647 in a3568ac @runtime_checkab...
X Description: This is more of a question, but I am a bit confused about the current definition of Container. Right now, it looks like it is typeshed/stdlib/typing.pyi Lines 643 to 647 in a3568ac @runtime_checkab...
Opengraph URL: https://github.com/python/typeshed/issues/15307
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Should `collections.abc.Container` be generic?","articleBody":"This is more of a question, but I am a bit confused about the current definition of `Container`. Right now, it looks like it is\n\nhttps://github.com/python/typeshed/blob/a3568ac8d9be04e7a10a6453068f4970e42074d5/stdlib/typing.pyi#L643-L647\n\nThis strikes me as an odd definition though: it has a generic parameter (that AFAIK is totally unused), and requires that `__contains__` always takes an `object` type. I feel like it would make sense to *either*:\n\n1. Make `Container` not generic (since AFAICT `Container[str]` vs `Container[int]` has no actual meaning)\n2. Make the type annotation on `def __contains__(self, x: _T_co, /) -> bool: ...` so that the generic parameter is actually used.\n\nNaively, option 2 seems to be more useful (since you can always have `Container[object]` if you want) but perhaps I am missing something?","author":{"url":"https://github.com/alanhdu","@type":"Person","name":"alanhdu"},"datePublished":"2026-01-20T17:37:43Z","url":"https://github.com/python/typeshed/issues/15307"}
| 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:ca84ab08-65d7-2eec-b417-f4eb329b25c1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C714:1833B7:224CFB7:2E7AACF:6B002601 |
| html-safe-nonce | 081895a7821db5c67f70aec3d0a1ec8b9cc29f5f1162da0974347aaae1c1f094 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzE0OjE4MzNCNzoyMjRDRkI3OjJFN0FBQ0Y6NkIwMDI2MDEiLCJ2aXNpdG9yX2lkIjoiODkxNDE0NDE4MTU2ODQxNTIzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2e745b3b33a325447195aa0f0f14d10622eeb4e7037a5294e64d484a3ff5e5d0 |
| hovercard-subject-tag | issue:3834740524 |
| 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/typeshed/15307/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4e6468f2fad617f78d083ac468b02d61009d4acda3ffffe3abcb74a1523ff4de/python/typeshed/issues/15307 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4e6468f2fad617f78d083ac468b02d61009d4acda3ffffe3abcb74a1523ff4de/python/typeshed/issues/15307 |
| og:image:alt | This is more of a question, but I am a bit confused about the current definition of Container. Right now, it looks like it is typeshed/stdlib/typing.pyi Lines 643 to 647 in a3568ac @runtime_checkab... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alanhdu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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