typing icon indicating copy to clipboard operation
typing copied to clipboard

[spec] Document `NotImplemented` special casing?

Open randolf-scholz opened this issue 2 months ago • 1 comments

Type checkers and typeshed special case NotImplemented to be treated as Any, this appears to be not documented in the spec currently.

A small paragraph should probably go here: https://typing.python.org/en/latest/spec/special-types.html

randolf-scholz avatar Nov 02 '25 10:11 randolf-scholz

I am not aware of a case where treating NotImplemented as Any is really useful, and recently opened python/mypy#20114 to remove this special casing from Mypy. An idea is to use NotImplemented / NotImplementedType to specify the behaviour of binary operators as discussed in #1548.

tyralla avatar Nov 07 '25 05:11 tyralla