
Oct. 7, 2020
1:34 a.m.
On Tue, Oct 06, 2020 at 09:30:06AM -0700, aleksiy123 wrote:
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.
Why do you care specifically about the `__str__` dunder? Calling str() is one of those protocols that should always succeed, whether the argument defines `__str__`, `__repr__`, or inherits from object. Ignoring the possibility of bugs or deliberate raising, I can't think of any object that doesn't support the str() protocol. Have I missed anything? -- Steve