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
|
@runtime_checkable |
|
class Container(Protocol[_T_co]): |
|
# This is generic more on vibes than anything else |
|
@abstractmethod |
|
def __contains__(self, x: object, /) -> bool: ... |
This 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:
- Make
Container not generic (since AFAICT Container[str] vs Container[int] has no actual meaning)
- Make the type annotation on
def __contains__(self, x: _T_co, /) -> bool: ... so that the generic parameter is actually used.
Naively, option 2 seems to be more useful (since you can always have Container[object] if you want) but perhaps I am missing something?