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

[IR,TE,TIR] Use f-strings for string formatting, NFC #14990

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

kparzysz-quic
Copy link
Contributor

Replace uses of % and .format() with f-strings.

Reformat modified files.

@tvm-bot
Copy link
Collaborator

tvm-bot commented May 30, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

Copy link
Member

@Hzfengsy Hzfengsy left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the work, but I'm curious about the reason behind these changes. Does it mean string formatting will be deprecated in the future by Python?

@kparzysz-quic
Copy link
Contributor Author

F-strings embed the expressions into the string itself, unlike % and format, which separate them from the string. This typically makes f-strings more compact and easier to read. This can be a judgment call sometimes and I tried not to sacrifice readability if the existing code was clearer than f-strings.

Maybe a small bonus for moving away from % is that % uses different format specification from format and f-strings. The latter two use the same one, so that helps with consistency a little bit.

I created the first PR not knowing how it will be received, but since the reception was positive, I decided to keep going.

@kparzysz-quic
Copy link
Contributor Author

Forgot to mention---I am not aware of any intentions to deprecate % from python. As far as I know it's here to stay.

Krzysztof Parzyszek added 2 commits June 1, 2023 05:02
Replace uses of % and .format() with f-strings.

Reformat modified files.
@kparzysz-quic kparzysz-quic merged commit 00126b0 into apache:main Jun 2, 2023
@kparzysz-quic kparzysz-quic deleted the f-strings-9 branch June 2, 2023 00:35
junrushao pushed a commit to junrushao/tvm that referenced this pull request Jun 22, 2023
* [IR,TE,TIR] Use f-strings for string formatting, NFC

Replace uses of % and .format() with f-strings.

Reformat modified files.

* Rearrange pylint directives for better formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants