Skip to content

Add basic support for PEP 798 - #21976

Merged
ilevkivskyi merged 5 commits into
python:masterfrom
ilevkivskyi:pep-798
Sep 18, 2026
Merged

ilevkivskyi merged 5 commits into
python:masterfrom
ilevkivskyi:pep-798

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Fixes #21489

Things are mostly straightforward. I also add support for old parser. Two non-trivial things:

  • I wrap constructor arguments instead of using ARG_STAR actual kind, because there is a limitation in argmap.py that it can't handle structural iterables. We have a bunch of issues open about this, and there were some attempts to fix it, but they stalled.
  • I force union inference for star-unpacks in comprehensions. Otherwise we will get too many builtins.object if we use joins. I think it is fine, since this is a new syntax.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread mypyc/irbuild/expression.py Outdated

def transform_generator_expr(builder: IRBuilder, o: GeneratorExpr) -> Value:
if isinstance(o.left_expr, StarExpr):
builder.error("PEP 798 is not supported yet", o.line)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also briefly mention that this is unsupported unpacking, since PEP numbers are not widely known? Maybe something like "Unsupported unpack (PEP 798 is not supported yet)".

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi
ilevkivskyi merged commit 0cf7ed7 into python:master Sep 18, 2026
25 checks passed
@ilevkivskyi
ilevkivskyi deleted the pep-798 branch September 18, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support PEP 798

3 participants