Title: `collections.abc.Set`, etc., missing `_from_iterable()` classmethod · Issue #15298 · python/typeshed · GitHub
Open Graph Title: `collections.abc.Set`, etc., missing `_from_iterable()` classmethod · Issue #15298 · python/typeshed
X Title: `collections.abc.Set`, etc., missing `_from_iterable()` classmethod · Issue #15298 · python/typeshed
Description: The base class for non-mutable abstract sets, collections.abc.Set (and a few others in Lib/_collections_abc.py) provide a classmethod(_from_iterable(Iterable[...]) -> Set[...]) (or similar) class method, which serves as a single place to...
Open Graph Description: The base class for non-mutable abstract sets, collections.abc.Set (and a few others in Lib/_collections_abc.py) provide a classmethod(_from_iterable(Iterable[...]) -> Set[...]) (or similar) class m...
X Description: The base class for non-mutable abstract sets, collections.abc.Set (and a few others in Lib/_collections_abc.py) provide a classmethod(_from_iterable(Iterable[...]) -> Set[...]) (or similar) clas...
Opengraph URL: https://github.com/python/typeshed/issues/15298
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`collections.abc.Set`, etc., missing `_from_iterable()` classmethod","articleBody":"The base class for non-mutable abstract sets, `collections.abc.Set` (and a few others in `Lib/_collections_abc.py`) provide a `classmethod(_from_iterable(Iterable[...]) -> Set[...])` (or similar) class method, which serves as a single place to override how the results of set-wise operations are constructed.\n\nC.f.: https://docs.python.org/3/library/collections.abc.html#examples-and-recipes\n\nThe class method in question, `_from_iterable()`, doesn't appear anywhere in typeshed (GitHub search of this repo, 2026-01-17).\n\n----\n\nMotivating example: I have a set-like class `Region` which acts as a set of all co-ordinates in a 2D area bounded min/max x and y co-ordinates. The results of set-wise operations involving a `Region` often aren't rectangular, and so can't be represented by a `Region`. Without `_from_iterable()`, `collections.abc.Set` tries to construct the result as `Region(\u003cIterable[Coord]>)`, which won't (and can't) work. By overriding `Set._from_iterable()` in `Region`, I can construct results as `set` or `frozenset` instances, which _can_ represent the results in all cases.\n\n","author":{"url":"https://github.com/finite-state-machine","@type":"Person","name":"finite-state-machine"},"datePublished":"2026-01-17T15:39:58Z","url":"https://github.com/python/typeshed/issues/15298"}
| 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:727f98ef-9b14-23ea-3e97-ea98039acd40 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AADE:3EE843:270132E:3552D9F:6B004855 |
| html-safe-nonce | 9f6fc982a2983d6f363b5ae2d5b1344ea05469fc47a899a40d4e7b4172c2f84b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQURFOjNFRTg0MzoyNzAxMzJFOjM1NTJEOUY6NkIwMDQ4NTUiLCJ2aXNpdG9yX2lkIjoiNjA0OTg1NzQxMjcyMTAzNTM0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | def6daf326c489f4f90a6c8ab77d7114931f9d8bd6f9ad9da63377e0b29f710e |
| hovercard-subject-tag | issue:3825427978 |
| 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/15298/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5839cea8b0eb0e1aea751fb9d818e80077f69d10509e17f20956a8602dcc7b4b/python/typeshed/issues/15298 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5839cea8b0eb0e1aea751fb9d818e80077f69d10509e17f20956a8602dcc7b4b/python/typeshed/issues/15298 |
| og:image:alt | The base class for non-mutable abstract sets, collections.abc.Set (and a few others in Lib/_collections_abc.py) provide a classmethod(_from_iterable(Iterable[...]) -> Set[...]) (or similar) class m... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | finite-state-machine |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width