Skip to content

Commit 8b9859a

Browse files
Copyedits to PEP 679 (python#2222)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 29ca7d7 commit 8b9859a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ pep-0675.rst @jellezijlstra
534534
pep-0676.rst @Mariatta
535535
pep-0677.rst @gvanrossum
536536
pep-0678.rst @iritkatriel
537+
pep-0679.rst @pablogsal
537538
# ...
538539
# pep-0754.txt
539540
# ...

pep-0679.rst

+15-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Python-Version: 3.11
1212
Abstract
1313
========
1414

15-
This pep proposes to allow parentheses surrounding the two-subject form of
15+
This PEP proposes to allow parentheses surrounding the two-argument form of
1616
assert statements. This will cause the interpreter to reinterpret what before
1717
would have been an assert with a two-element tuple that will always be True
1818
(``assert (expression, message)``) to an assert statement with a subject and a
@@ -23,22 +23,21 @@ failure message, equivalent to the statement with the parentheses removed
2323
Motivation
2424
==========
2525

26-
Is a common user mistake when using the form of the assert stamens that includes
27-
the error message to surround it by parentheses. Unfortunately, this mistake
28-
passes undetected as the assert will always pass due the the fact that is
26+
It is a common user mistake when using the form of the assert statement that includes
27+
the error message to surround it with parentheses. Unfortunately, this mistake
28+
passes undetected as the assert will always pass, because it is
2929
interpreted as an assert statement where the expression is a two-tuple, which
3030
always has truth-y value.
3131

32-
The mistake most often happens when extending thing or description beyond a
33-
single line on assert statements as () are the natural way to do that and as it
34-
is with assert being a statement.
32+
The mistake most often happens when extending the test or description beyond a
33+
single line, as parentheses are the natural way to do that.
3534

3635
This is so common that a ``SyntaxWarning`` is `now emitted by the compiler
3736
<https://bugs.python.org/issue35029>`_.
3837

3938
Additionally, some other statements in the language allow parenthesized forms
40-
in one way or another like ``import`` statements (``from x import (a,b,c)``), ``del``
41-
statements (``del (a,b,c)``).
39+
in one way or another like ``import`` statements (``from x import (a,b,c)``) and
40+
``del`` statements (``del (a,b,c)``).
4241

4342
Allowing parentheses not only will remove the common mistake but also will allow
4443
users and auto-formatters to format long assert statements over multiple lines
@@ -65,13 +64,13 @@ the formatting of other grammar constructs::
6564
"message",
6665
)
6766

68-
This change have been originally discussed and proposed in [bpo-46167]_.
67+
This change has been originally discussed and proposed in [bpo-46167]_.
6968

7069
Rationale
7170
=========
7271

7372
This change can be implemented in the parser or in the compiler. We have
74-
selected implementing this change in the parser because doing in in the compiler
73+
selected implementing this change in the parser because doing it in the compiler
7574
will require re-interpreting the AST of an assert statement with a two-tuple::
7675

7776
Module(
@@ -94,16 +93,16 @@ as the AST of an assert statement with an expression and a message::
9493
type_ignores=[])
9594

9695
The problem with this approach is that the AST of the first form will
97-
technically be "incorrect" as we already have an specialized form for the AST of
98-
an assert statement with an expression and a message (the second one). This
96+
technically be "incorrect" as we already have a specialized form for the AST of
97+
an assert statement with a test and a message (the second one). This
9998
means that many tools that deal with ASTs will need to be aware of this change
10099
in semantics, which will be confusing as there is already a correct form that
101100
better expresses the new meaning.
102101

103102
Specification
104103
=============
105104

106-
This PEP proposes changing the grammar from the ``assert`` statement to: ::
105+
This PEP proposes changing the grammar of the ``assert`` statement to: ::
107106

108107
| 'assert' '(' expression ',' expression [','] ')' &(NEWLINE | ';')
109108
| 'assert' a=expression [',' expression ]
@@ -124,11 +123,11 @@ The change is not technically backwards compatible, as parsing ``assert (x,y)``
124123
is currently interpreted as an assert statement with a 2-tuple as the subject,
125124
while after this change it will be interpreted as ``assert x,y``.
126125

127-
On the other hand, this kind of assert statements are always true so they are
126+
On the other hand, assert statements of this kind always pass, so they are
128127
effectively not doing anything in user code. The authors of this document think
129128
that this backwards incompatibility nature is beneficial, as it will highlight
130129
these cases in user code while before they will have passed unnoticed (assuming that
131-
these cases still exist is because users are ignoring syntax warnings).
130+
these cases still exist because users are ignoring syntax warnings).
132131

133132
Security Implications
134133
=====================

0 commit comments

Comments
 (0)