← 返回首页
gh-90325: Allow assert statements with parentheses by pablogsal · Pull Request #30247 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

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 commented Dec 24, 2021
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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

https://bugs.python.org/issue46167

Copy link
Copy Markdown

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

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

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

Copy link
Copy Markdown
Member

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Footer

© 2026 GitHub, Inc.