basedpyright
basedpyright copied to clipboard
Research if the collections should be `Protocol`s or `ABC`s
typing.pyi:
@runtime_checkable
class Iterable(Protocol[_T_co]):
@abstractmethod
def __iter__(self) -> Iterator[_T_co]: ...
_collections_abc.py:
class Iterable(metaclass=ABCMeta):
__slots__ = ()
@abstractmethod
def __iter__(self):
while False:
yield None
@classmethod
def __subclasshook__(cls, C):
if cls is Iterable:
return _check_methods(C, "__iter__")
return NotImplemented
while not being Protocols at runtime, they act like them, and they are both ABCMeta, so this is a fairly correct approximation
related? https://github.com/microsoft/pyright/issues/6624
#352 fixes the annoying reportMissingSuperCall errors on abstract methods, which makes me want to prioritize this as converting these to ABCs will make them far less annoying to work with. specifically AbstractContextManager.__enter__
oh wait, it actually fixes that case too nvm