GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-104799: PEP 695 backward compatibility for ast.unparse by JelleZijlstra · Pull Request #105846 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Jun 16, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: PEP-695: Potentially breaking changes made to __match_args__ attributes of AST nodes #104799

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JelleZijlstra
pythongh-104799: PEP 695 backward compatibility for ast.unparse
eda4009
@JelleZijlstra
JelleZijlstra marked this pull request as ready for review June 16, 2023 01:12
@JelleZijlstra
JelleZijlstra requested a review from isidentical as a code owner June 16, 2023 01:12
@bedevere-bot bedevere-bot mentioned this pull request Jun 16, 2023
PEP-695: Potentially breaking changes made to __match_args__ attributes of AST nodes #104799
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Jun 16, 2023
@JelleZijlstra JelleZijlstra added the needs backport to 3.12 only security fixes label Jun 16, 2023
@AlexWaygood
AlexWaygood self-requested a review June 16, 2023 07:57
AlexWaygood
AlexWaygood reviewed Jun 16, 2023
View reviewed changes
Comment thread Lib/ast.py
self.traverse(deco)
self.fill("class " + node.name)
self._type_params_helper(node.type_params)
if hasattr(node, "type_params"):

@AlexWaygood AlexWaygood Jun 16, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I assume it would be harder to just make sure that these nodes always have a type_params attribute, even if the relevant argument wasn't passed to the constructor?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra Jun 16, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes, that might be something to pursue for 3.13 though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra Jun 16, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

#105858

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
AlexWaygood
AlexWaygood approved these changes Jun 16, 2023
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_unparse.py
def test_function(self):
node = ast.FunctionDef(
name="f",
args=ast.arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]),

@AlexWaygood AlexWaygood Jun 16, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

#105858 would make this so much easier; manual creation like this feels ridiculously tedious at the moment

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/test/test_unparse.py
ast.fix_missing_locations(node)
self.assertEqual(ast.unparse(node), "def f[T]():\n pass")

def test_function_with_type_params_and_bound(self):

@AlexWaygood AlexWaygood Jun 16, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Worth also adding a test_function_with_type_params_and_constraints, for completeness?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra Jun 16, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Feels a bit repetitive, it's the same at the AST level.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Jun 16, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fair enough!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jun 16, 2023
@JelleZijlstra
JelleZijlstra merged commit 957a974 into python:main Jun 16, 2023
@miss-islington

miss-islington commented Jun 16, 2023

Copy link
Copy Markdown
Contributor

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label Jun 16, 2023
@miss-islington

miss-islington commented Jun 16, 2023

Copy link
Copy Markdown
Contributor

Sorry @JelleZijlstra, I had trouble checking out the 3.12 backport branch.
Please retry by removing and re-adding the "needs backport to 3.12" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 957a974d4fc1575787e4a29a399a47520d6df6d3 3.12

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra
JelleZijlstra deleted the unparse branch June 16, 2023 16:31
@miss-islington miss-islington assigned JelleZijlstra Jun 16, 2023
@JelleZijlstra JelleZijlstra added needs backport to 3.12 only security fixes and removed needs backport to 3.12 only security fixes labels Jun 16, 2023
@miss-islington

miss-islington commented Jun 16, 2023

Copy link
Copy Markdown
Contributor

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 16, 2023
@JelleZijlstra @miss-islington
pythongh-104799: PEP 695 backward compatibility for ast.unparse (pyth…
b23dad6
…onGH-105846)

(cherry picked from commit 957a974)

Co-authored-by: Jelle Zijlstra <[email protected]>
@bedevere-bot

bedevere-bot commented Jun 16, 2023

Copy link
Copy Markdown

GH-105862 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jun 16, 2023
JelleZijlstra added a commit that referenced this pull request Jun 16, 2023
@miss-islington @JelleZijlstra
[3.12] gh-104799: PEP 695 backward compatibility for ast.unparse (GH-…
5ca707d
…105846) (#105862)

(cherry picked from commit 957a974)

Co-authored-by: Jelle Zijlstra <[email protected]>
carljm added a commit to carljm/cpython that referenced this pull request Jun 16, 2023
@carljm
Merge branch 'main' into modulelocals
b096651
* main:
  pythongh-104799: PEP 695 backward compatibility for ast.unparse (python#105846)
  pythongh-105834: Add tests for calling `issubclass()` between two protocols (python#105835)
  CI: Remove docs build from Azure Pipelines (python#105823)
  pythongh-105844: Consistently use 'minor version' for X.Y versions (python#105851)
  Fix inaccuracies in "Assorted Topics" section of "Defining Extension Types" tutorial (python#104969)
  pythongh-105433: Add `pickle` tests for PEP695 (python#105443)
  bpo-44530: Document the change in MAKE_FUNCTION behavior (python#93189)
  pythonGH-103124: Multiline statement support for pdb (pythonGH-103125)
  pythonGH-105588: Add missing error checks to some obj2ast_* converters (pythonGH-105589)
gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Jun 18, 2023
@JelleZijlstra @gvanrossum
pythongh-104799: PEP 695 backward compatibility for ast.unparse (pyth…
bc91df7
…on#105846)
@JelleZijlstra
JelleZijlstra restored the unparse branch September 10, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexWaygood AlexWaygood AlexWaygood approved these changes
@isidentical isidentical Awaiting requested review from isidentical isidentical is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@JelleZijlstra JelleZijlstra

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@JelleZijlstra @miss-islington @bedevere-bot @AlexWaygood
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.