Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-113317: Argument Clinic: tear out internal text accumulator APIs #113402

Merged
merged 5 commits into from
Dec 22, 2023

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Dec 22, 2023

Replace the internal accumulator APIs by using lists of strings and join().

Yak-shaving for separating out formatting code into a separate file.

…APIs

Replace the internal accumulator APIs by using lists of strings and join().

Yak-shaving for separating out formatting code into a separate file.
"""
text, append, output = _text_accumulator()
return TextAccumulator(append, output)
TextAccumulator = list[str]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use this other places. For example in the c-render-data structure. But I'm not sure it adds much value.

"""
text, append, output = _text_accumulator()
return TextAccumulator(append, output)
TextAccumulator = list[str]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this type alias isn't actually used until much further down in the file. Could we maybe move it to line 2345 or something?

Copy link
Member

@AlexWaygood AlexWaygood Dec 22, 2023

Choose a reason for hiding this comment

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

Or we can just get rid of it, like you propose in #113402 (comment)! I'm easy either way. Getting rid of it might be best for now, it isn't immediately obvious what a "TextAccumulator" means in terms of the types involved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it makes sense to declare it just above BufferSeries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially kept it, just to keep the diff down, but I'm fine with letting it go. I prefer deal with it in a follow-up PR, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the PR: #113413

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

This is great -- a big readability improvement, imo. And much less code for us to maintain!

We could use this other places. For example in the c-render-data structure. But I'm not sure it adds much value.

We posted comments simultaneously, I think -- I'd be happy to see the TextAccumulator type alias gone, as I mentioned in #113402 (comment)! But I'm also fine with it staying, if you prefer it :)

Tools/clinic/clinic.py Show resolved Hide resolved
Tools/clinic/clinic.py Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <[email protected]>
@erlend-aasland erlend-aasland merged commit daa658a into python:main Dec 22, 2023
33 checks passed
@erlend-aasland erlend-aasland deleted the clinic/remove-accumulator branch December 22, 2023 20:28
@erlend-aasland
Copy link
Contributor Author

Thanks for the review and suggestions, Alex!

erlend-aasland added a commit to erlend-aasland/cpython that referenced this pull request Dec 22, 2023
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
…APIs (python#113402)

Replace the internal accumulator APIs by using lists of strings and join().

Yak-shaving for separating out formatting code into a separate file.

Co-authored-by: Alex Waygood <[email protected]>
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
…APIs (python#113402)

Replace the internal accumulator APIs by using lists of strings and join().

Yak-shaving for separating out formatting code into a separate file.

Co-authored-by: Alex Waygood <[email protected]>
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…APIs (python#113402)

Replace the internal accumulator APIs by using lists of strings and join().

Yak-shaving for separating out formatting code into a separate file.

Co-authored-by: Alex Waygood <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…APIs (python#113402)

Replace the internal accumulator APIs by using lists of strings and join().

Yak-shaving for separating out formatting code into a separate file.

Co-authored-by: Alex Waygood <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants