Currently there are a few Protocols https://docs.python.org/3/library/typing.html#protocols defined in the typing module. One that I recently felt like was missing was a typing annotation for classes with a __str__() method defined. Seems like a fairly straightforward implementation._______________________________________________
@runtime_checkable class SupportsString(Protocol): """An ABC with one abstract method __str__.""" __slots__ = () @abstractmethod def __str__(self) -> str: pass Perhaps there is another way to do this that I am missing?
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/C66MLTYQNAL3KHZELGME62UQOVGAHM5L/
Code of Conduct: http://python.org/psf/codeofconduct/