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.
There was a problem hiding this comment.
Great point. You're right that __matmul__ on NoneType is a special case with potential runtime risks since None relies on __ror__. I've removed the claim and moved the None debate down to a new "Open Issues" section.
| 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.
There was a problem hiding this comment.
Apologies, I got carried away! I agree that changing the default evaluation strategy is a massive separate undertaking. I've completely removed the sentence.
c8917dc to
9d15ddc
Compare
9d15ddc to
5594c7c
Compare


This PR incorporates recent feedback from the Discourse discussion for PEP 835. Specifically, it:
type(None)supportFORWARDREF_STRUCTURALmechanism to the Specification section