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-95065: Argument Clinic: Pretty-print long C strings in generated code#107712

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

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aaslanderlend-aasland commentedAug 7, 2023
edited by bedevere-bot
Loading

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Could nottextwrap.wrap(replace_whitespace=False, drop_whitespace=False) be used here?

@erlend-aasland
Copy link
ContributorAuthor

Could nottextwrap.wrap(replace_whitespace=False, drop_whitespace=False) be used here?

Perhaps. I experimented a little bit withtextwrap.TextWrapper but it does not support custom suffix like line continuation characters.

@erlend-aasland
Copy link
ContributorAuthor

erlend-aasland commentedAug 7, 2023
edited
Loading

A simpler approach could be to usetextwrap,thensplit("\n") and prepend/append the needed quotes and continuation:

wrapped=textwrap.wrap(...)forlineinwrapped:# add indent, add quoted line, add suffix and newline

@serhiy-storchaka
Copy link
Member

prefix + separator.join(textwrap.wrap(...)) + suffix

@erlend-aaslanderlend-aaslandforce-pushed theac-deprecate-pprint-c-strings branch fromb2d7f3a to68c1b1eCompareAugust 7, 2023 12:48
@erlend-aasland
Copy link
ContributorAuthor

prefix + separator.join(textwrap.wrap(...)) + suffix

Unfortunately, not so simple.

@erlend-aasland
Copy link
ContributorAuthor

For example, we don't want the suffix to be applied to the last line.

@erlend-aasland
Copy link
ContributorAuthor

I think3de2378 should do the trick.

Comment on lines +227 to +230
width:int=72,
suffix:str='',
initial_indent:int=0,
subsequent_indent:int=4
Copy link
Member

Choose a reason for hiding this comment

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

It seems all call sites specify a value for thesubsequent_indent parameter. Maybe it should be required, instead of optional?

Suggested change
width:int=72,
suffix:str='',
initial_indent:int=0,
subsequent_indent:int=4
subsequent_indent:int,
width:int=72,
suffix:str='',
initial_indent:int=0,

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hm, perhaps.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@erlend-aaslanderlend-aaslandenabled auto-merge (squash)August 7, 2023 14:15
@erlend-aasland
Copy link
ContributorAuthor

Thank you for the reviews!

AlexWaygood reacted with heart emoji

@erlend-aaslanderlend-aasland merged commit835e388 intopython:mainAug 7, 2023
@erlend-aaslanderlend-aasland deleted the ac-deprecate-pprint-c-strings branchAugust 7, 2023 14:41
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@AlexWaygoodAlexWaygoodAlexWaygood approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@erlend-aasland@serhiy-storchaka@AlexWaygood@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp