Skip to content

assert a := 1 produces unclear error message #138716

Closed

Description

@sobolevn

Feature or enhancement

After 6bc65c3 is merged, there's one more case we can handle. See this todo:

>>> # TODO(@sobolevn): improve this message in the next PR
>>> assert a := 1
Traceback (most recent call last):
SyntaxError: invalid syntax

What happens? assert does not allow := without () in its body.
We need to improve the error message, because current state is not really clear for the user. Why there's a syntax error? How to fix it?

Refs #136616

Linked PRs

Activity

  1. self-assigned this
    on Sep 9, 2025
  2. added 3 commits that reference this issue on Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.15bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions