-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
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
Lines 643 to 647 in a3568ac
| @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
Containernot generic (since AFAICTContainer[str]vsContainer[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?
Metadata
Metadata
Assignees
Labels
No labels