The formal term for that is intersection types. There is a long-standing thread about that at; there are some uses but the feature would greatly complicate the type system, so it's not clear that it's worth adding.

At this point, what Intersection needs is someone to champion the proposal and write a PEP.

El lun, 24 abr 2023 a las 6:21, Mathew Elman (<>) escribió:
Rather than changing Protocols and affecting lots of users, it seems like was you really want is a generic class that is the "and" to Union's "or"? e.g.

def foo(thing: All[Thread, SupportsStop]):

which seems reasonable. If that appeals to you, then you probably want to raise that on the typing thread?
Python-ideas mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct: