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-134551: Add t-strings support to pprint#134577

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

Open
loic-simon wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromloic-simon:add-templates-to-pprint

Conversation

loic-simon
Copy link
Contributor

@loic-simonloic-simon commentedMay 23, 2025
edited by bedevere-appbot
Loading

Handle formatting ofTemplate andInterpolation types inpprint functions:

>>>from pprintimport pp>>> name="World">>> pp(t"Hello{World}")Template(strings=('Hello ', ''),         interpolations=(Interpolation('World', 'name', None, ''),))""")

Very straightforward, using existingPrettyPrinter helper methods.

To avoid slowing import time, I did not importTemplate andInterpolation fromstring.templatelib, but instead copied their (very simple) definition:

t=t"{0}"
Template=type(t)
Interpolation=type(t.interpolations[0])
delt

@loic-simon
Copy link
ContributorAuthor

loic-simon commentedMay 23, 2025
edited
Loading

Not sure whytest.test_tokenize.TestRoundtrip.test_random_files fails ontest_pprint.py? If I replace t-strings by f-strings it pass, is it an issue with the test not handling t-strings? Or a real issue with tokenizer round-trippring and t-strings?

Edit: looks like a real problem, I have a MRE, opening an issue soon

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@hugovkhugovkhugovk left review comments

@AlexWaygoodAlexWaygoodAwaiting requested review from AlexWaygoodAlexWaygood is a code owner

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@loic-simon@hugovk

[8]ページ先頭

©2009-2025 Movatter.jp