Skip to content

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Dec 24, 2021

⚠️ PR created just to evaluate the solution, a PEP is needed before merging ⚠️

https://bugs.python.org/issue46167

@github-actions
Copy link

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
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
>>> 

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