Skip to content

gh-90325: Allow assert statements with parentheses#30247

Closed
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:bpo-46167
Closed

gh-90325: Allow assert statements with parentheses#30247
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:bpo-46167

Conversation

@pablogsal
Copy link
Copy Markdown
Member

@pablogsal pablogsal commented Dec 24, 2021

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jan 25, 2022
@StanFromIreland StanFromIreland changed the title bpo-46167: Allow assert statements with parentheses gh-90325: Allow assert statements with parentheses Aug 18, 2025
@StanFromIreland
Copy link
Copy Markdown
Member

Just leaving a note here, the new syntax as implemented by the grammar change is not always consistent with the standard from. For example:

>>> t = ()
>>> assert *t # Standard form, raises SyntaxError
  File "<python-input-7>", line 1
    assert *t
           ^
SyntaxError: invalid syntax
>>> assert (*t, "error message") # New syntax is not used, passes due to the second element
<python-input-9>:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?

Also, the current warning is not always correct:

>>> assert (*t,)
<python-input-6>:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?
Traceback (most recent call last):
  File "<python-input-6>", line 1, in <module>
    assert (*t,)
           ^^^^^
AssertionError
>>> 

@StanFromIreland
Copy link
Copy Markdown
Member

Closing this PR as with updates to PEP 679 the planned implementation has changed.

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

Labels

awaiting core review DO-NOT-MERGE stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants