-
Notifications
You must be signed in to change notification settings - Fork 288
Closed
Description
In typing.py, a number of built-in protocols extend from Generic, not Protocol (eg Iterable, Container, Sized, etc). However, at runtime the Procotol class enforces that all bases for a class also inherit from Protocol. Thus the following code
from typing import Iterable, TypeVar
from typing_extensions import Protocol
T = TypeVar('T')
class Foo(Iterable[T], Protocol[T]):
passcauses the error
TypeError: Protocols can only inherit from other protocols, got typing.Iterable
This is further confused by the fact that, in recent versions of typeshed, typing.pyi has these types like Iterable extending Protocol and not Generic (opposite of runtime, but also seemingly the more "correct" version).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels