Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions peps/pep-0679.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Status: Draft
Type: Standards Track
Created: 07-Jan-2022
Python-Version: 3.15
Post-History: `10-Jan-2022 <https://discuss.python.org/t/pep-679-allow-parentheses-in-assert-statements/13003>`__
Post-History: `08-Sep-2025 <https://discuss.python.org/t/pep-679-new-assert-statement-syntax-with-parentheses/103634>`__,
`10-Jan-2022 <https://discuss.python.org/t/pep-679-allow-parentheses-in-assert-statements/13003>`__


Abstract
Expand Down Expand Up @@ -132,10 +133,10 @@ specification.
(Note that, without the warning specification the pure parser implementation is
a small grammar change [#previmp]_).
To raise the warning, the compiler must
be aware of the new syntax, which means that a flag would be necessary as
otherwise the information is lost during parsing.
As such, the AST of an :keyword:`assert` would look like so,
with a ``paren_syntax`` flag::
be aware of the new syntax, this means that an optional flag would be necessary
as otherwise the information is lost during parsing.
As such, the AST of an :keyword:`assert` with parentheses would look like so,
with a ``paren_syntax=1`` flag::

>>> print(ast.dump(ast.parse('assert(True, "Error message")'), indent=4))
Module(
Expand All @@ -145,8 +146,6 @@ with a ``paren_syntax`` flag::
msg=Constant(value='Error message'),
paren_syntax=1)])

The flag would be removed in 3.18 along with the :exc:`SyntaxWarning`.


Implementing in the compiler
----------------------------
Expand Down