You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement _from_iterable on builtins.set andbuiltins.frozenset #144557
However, builtins.frozenset and builtins.set, which are marked as inherting from Set and MutableSet, do not implement this constructor, therefore typeshed is kind of blocked from adding these methods in the stubs, as it would lead to unsafe code:
deff(x: MutableSet) ->MutableSet:
# passes type checking if _from_iterable is added to MutableSetreturntype(x)._from_iterable(x)
f( {1,2,3} ) # Error at runtime
Alternatives
typeshed could just decide to never add the _from_iterable method, people can still override it regardless to get the desired runtime behavior on types that use the Set and MutableSet mixins that rely on this method.
I am not entirely sure we can do anything here. Changing builtins requires a PEP. If this is for the sake of completeness with typing, I'm not sure it's worth.
Reacted by Jelle Zijlstra, Peter Bierma, Raymond Hettinger, Erlend E. Aasland and Randolf Scholz
Activity
picnixz commentedon Feb 7, 2026
I am not entirely sure we can do anything here. Changing builtins requires a PEP. If this is for the sake of completeness with typing, I'm not sure it's worth.
randolf-scholz commentedon Feb 11, 2026
That's totally fair, but important feedback for
typeshedon whether to include this method in the stubs.