Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-104799: PEP 695 backward compatibility for ast.unparse#105846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 1 commit intopython:mainfromJelleZijlstra:unparse
Jun 16, 2023

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commentedJun 16, 2023
edited by bedevere-bot
Loading

@@ -1051,7 +1051,8 @@ def visit_ClassDef(self, node):
self.fill("@")
self.traverse(deco)
self.fill("class " + node.name)
self._type_params_helper(node.type_params)
if hasattr(node, "type_params"):
Copy link
Member

@AlexWaygoodAlexWaygoodJun 16, 2023
edited
Loading

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 atype_params attribute, even if the relevant argument wasn't passed to the constructor?

Copy link
MemberAuthor

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.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM

def test_function(self):
node = ast.FunctionDef(
name="f",
args=ast.arguments(posonlyargs=[], args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]),
Copy link
Member

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

JelleZijlstra reacted with thumbs up emoji
ast.fix_missing_locations(node)
self.assertEqual(ast.unparse(node), "def f[T]():\n pass")

def test_function_with_type_params_and_bound(self):
Copy link
Member

Choose a reason for hiding this comment

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

Worth also adding atest_function_with_type_params_and_constraints, for completeness?

Copy link
MemberAuthor

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.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough!

@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

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

@JelleZijlstraJelleZijlstra deleted the unparse branchJune 16, 2023 16:31
@JelleZijlstraJelleZijlstra added needs backport to 3.12only security fixes and removed needs backport to 3.12only security fixes labelsJun 16, 2023
@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 16, 2023
…onGH-105846)(cherry picked from commit957a974)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-bot
Copy link

GH-105862 is a backport of this pull request to the3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelJun 16, 2023
JelleZijlstra added a commit that referenced this pull requestJun 16, 2023
…105846) (#105862)(cherry picked from commit957a974)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
carljm added a commit to carljm/cpython that referenced this pull requestJun 16, 2023
* 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 requestJun 18, 2023
@JelleZijlstraJelleZijlstra restored the unparse branchSeptember 10, 2024 23:37
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AlexWaygoodAlexWaygoodAlexWaygood approved these changes

@isidenticalisidenticalAwaiting requested review from isidenticalisidentical is a code owner

Assignees

@JelleZijlstraJelleZijlstra

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@JelleZijlstra@miss-islington@bedevere-bot@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp