PEP 835: Address Discourse feedback from encukou and tjreedy#4998
PEP 835: Address Discourse feedback from encukou and tjreedy#4998till-varoquaux wants to merge 1 commit into
Conversation
Documentation build overview
|
| supported for any left-hand operand that currently supports the ``|`` | ||
| operator for making a union. | ||
| operator for making a union (including ``type(None)``, which acts as the | ||
| canonical equivalent to ``None`` in type hints). |
There was a problem hiding this comment.
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.
| pre-existing issue with ``|`` unions, where ``"Foo" | int`` under | ||
| ``Format.FORWARDREF`` produces ``ForwardRef('Foo | int')`` instead of the | ||
| structural ``ForwardRef('Foo') | int``. | ||
| structural ``ForwardRef('Foo') | int``. Notably, if ``FORWARDREF_STRUCTURAL`` |
There was a problem hiding this comment.
Seems very speculative; there are lots of problems that would need to be solved before this can be entertained.
This PR incorporates recent feedback from the Discourse discussion for PEP 835. Specifically, it:
type(None)supportFORWARDREF_STRUCTURALmechanism to the Specification section