Skip to content

PEP 835: Address Discourse feedback from encukou and tjreedy#4998

Open
till-varoquaux wants to merge 1 commit into
python:mainfrom
till-varoquaux:feature/update-pep835-links
Open

PEP 835: Address Discourse feedback from encukou and tjreedy#4998
till-varoquaux wants to merge 1 commit into
python:mainfrom
till-varoquaux:feature/update-pep835-links

Conversation

@till-varoquaux

Copy link
Copy Markdown
Contributor

This PR incorporates recent feedback from the Discourse discussion for PEP 835. Specifically, it:

  • Clarifies type(None) support
  • Promotes the FORWARDREF_STRUCTURAL mechanism to the Specification section
  • Bumps the deprecation timeline for the compatibility shim to Python 3.21 to align with PEP 387
  • Clarifies the phrasing around stringified annotations under PEP 563

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #33211276 | 📁 Comparing c8917dc against latest (f101f94)

  🔍 Preview build  

1 file changed
± pep-0835/index.html

Comment thread peps/pep-0835.rst
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).

Copy link
Copy Markdown
Member

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.

Comment thread peps/pep-0835.rst
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``

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems very speculative; there are lots of problems that would need to be solved before this can be entertained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants