◐ Shell
clean mode source ↗

PEP 835: Address Discourse feedback from encukou and tjreedy by till-varoquaux · Pull Request #4998 · python/peps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a questionable claim; some parts of typing.py turn None into NoneType but not all typing APIs do.

Also the mention of NoneType is a bit confusing. NoneType is a type like any other, so it inherits __or__ (currently) and __matmul__ (if this PEP is accepted) from type. The more interesting question is what happens to None itself. Currently, it does not in fact support __or__; None | int works, but that's through the latter's __ror__. Therefore, unions of None with a stringified type (None | "int") fail at runtime. You are proposing to make matmul work for None.