Specify what happens for binary operators (e.g. __add__
)
#1548
Labels
topic: typing spec
For improving the typing spec
__add__
)
#1548
There's a subtle dance around
__add__
,__radd__
, andNotImplemented
. While most of the rules are in the language spec, I think we haven't specified carefully what the signature should be of e.g. the__add__
method, especially when annotations are inline. (At least, I didn't find any mention ofNotImplemented
in the spec.)In typeshed we seem to ignore the "overload"
__add__: (Any) -> Literal[NotImplemented]
(to be loose with notation), but what do typecheckers do when they see a concrete__add__
or__eq__
implementation that can returnNotImplemented
?The text was updated successfully, but these errors were encountered: