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
collections.abc.Set does not support Iterable s in some dunder methods #14659
As the linked PR shows, there's a conflict between what the abstract base class supports and what the (virtual) set protocol (which should be represented by collections.abc.Set) supports. It's unfortunate that AbstractSet accepts a broader interface than what its (virtual) sub-classes like set do, basically breaking the LSP.
I'm unsure what the correct solution is, but I slightly prefer exploring the approach in #14653 together with enforcing not to use those pseudo-protocols in argument positions. At least the LSP violations are made explicit.
Activity
srittau commentedon Sep 3, 2025
As the linked PR shows, there's a conflict between what the abstract base class supports and what the (virtual) set protocol (which should be represented by
collections.abc.Set) supports. It's unfortunate thatAbstractSetaccepts a broader interface than what its (virtual) sub-classes likesetdo, basically breaking the LSP.That's one of the reasons why these pseudo-protocols shouldn't be used in argument annotations (see also PyCQA/flake8-pyi#508 and PyCQA/flake8-pyi#525).
I'm unsure what the correct solution is, but I slightly prefer exploring the approach in #14653 together with enforcing not to use those pseudo-protocols in argument positions. At least the LSP violations are made explicit.