Skip to content

Commit db49283

Browse files
Footnote
1 parent 51094d5 commit db49283

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

peps/pep-0679.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ is out of the scope of this PEP.
9696
Specification
9797
=============
9898

99-
The formal grammar of the :keyword:`assert` statement will change to:
99+
The formal grammar of the :keyword:`assert` statement will change to [#edgecase]_:
100100

101101
.. code-block::
102102
@@ -115,7 +115,7 @@ The specification that a :exc:`SyntaxWarning` be raised informing users
115115
of the new syntax complicates the implementation, as warnings
116116
should be raised during compilation.
117117

118-
The authors believe that an ideal implementation would be in the parser,
118+
The authors believe that an ideal implementation would be in the parser [#edgecase]_,
119119
resulting in ``assert (x,y)`` having the same AST as ``assert x,y``.
120120
This necessitates a two-step implementation plan, with a necessary temporary
121121
compromise.
@@ -282,14 +282,29 @@ Footnotes
282282
=========
283283

284284
.. [#SO1] `StackOverflow: "'assert' statement with or without parentheses" <https://stackoverflow.com/questions/3112171/assert-statement-with-or-without-parentheses>`_
285+
285286
.. [#RD] `/r/python: "Rant: use that second expression in assert! " <https://www.reddit.com/r/Python/comments/1n87g91/rant_use_that_second_expression_in_assert/>`_
287+
286288
.. [#fl8] `flake8: Rule F631 <https://flake8.pycqa.org/en/latest/user/error-codes.html>`_
289+
287290
.. [#pylint] `pylint: assert-on-tuple (W0199) <https://pylint.pycqa.org/en/latest/user_guide/checkers/features.html>`_
291+
288292
.. [#previmp] For the previous parser implementation, see :cpython-pr:`30247`
293+
289294
.. [#exception] During the updating of this PEP, an exception
290295
(``assert (*(t := ()),)``) was found, contradicting the warning.
296+
291297
.. [#assertwith] `[DPO] Pre-PEP: Assert-with: Dedicated syntax for assertion messages <https://discuss.python.org/t/pre-pep-assert-with-dedicated-syntax-for-assertion-messages/13247>`_
292298
299+
.. [#edgecase] An edge case arises with constructs like:
300+
301+
>>> x = (0,)
302+
>>> assert (*x, "edge cases aren't fun:-(")
303+
304+
This form is currently parsed as a single tuple expression, not
305+
as a condition/message pair, and will need explicit handling in
306+
the compiler.
307+
293308
294309
Copyright
295310
=========

0 commit comments

Comments
 (0)