Uh oh!
There was an error while loading. Please reload this page.
GH-45619: [Python] Use f-string instead of string.format - #45629
Conversation
kou
commented
Feb 26, 2025
We have many |
chilin0525
commented
Feb 26, 2025
@kou Thank you for the reminder🙏. I personally prefer to implement all changes within a single PR, so I am converting the PR to draft status. |
chilin0525
commented
Mar 1, 2025
I have already changed all the files under the pyarrow folder. As discussed in #45619, certain scenarios where the template is reused across multiple methods using |
raulcd
left a comment
There was a problem hiding this comment.
Thanks for the PR, could you take a look on the CI failures:
https://github.com/apache/arrow/actions/runs/13620611692/job/38077510062?pr=45629#step:6:8540
There are some cases were the expected doctest is failing due to the changes.
| def __repr__(self): | ||
| return "<pyarrow.acero.Declaration>\n{0}".format(str(self)) | ||
| return f"<pyarrow.acero.Declaration>\n{str(self)}" |
There was a problem hiding this comment.
str is implicit in f-strings, you don't need to call it explicitly. Example:
>>>fromdecimalimportDecimal>>>d=Decimal('1.500')
>>>repr(d)
"Decimal('1.500')">>>str(d)
'1.500'>>>f"d is {d}"'d is 1.500'>>>f"d is {d!r}""d is Decimal('1.500')"There was a problem hiding this comment.
Thanks for review! I will change this.
chilin0525
commented
Mar 6, 2025
pitrou
commented
Mar 6, 2025
You can, but you don't have to. It's as you prefer. |
chilin0525
commented
Mar 6, 2025
Got it! I prefer to update all files in this PR, so I will mark it as a draft until all changes are made. Thanks! |
chilin0525
commented
Apr 6, 2025
kou
commented
Apr 6, 2025
"C GLib & Ruby / AMD64 Windows MSVC GLib" will be fixed by #46006 . |
raulcd
left a comment
There was a problem hiding this comment.
@chilin0525 will you have some time to rebase main and fix the conflicts?
chilin0525
commented
May 10, 2025
@raulcd I've rebased onto main and resolved the conflicts. The CI error looks unrelated to this change. Let me know if there's anything else I should adjust. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
raulcd
commented
May 12, 2025
@github-actions crossbow submit -g python |
raulcd
left a comment
There was a problem hiding this comment.
I've applied some minor suggestions and fixed a new conflict with main. If CI is successful I am going to merge.
Revision: 7079403 Submitted crossbow builds: ursacomputing/crossbow @ actions-11bf920665 |
raulcd
commented
May 12, 2025
The CI failures are unrelated. The Python 3.10 are related to the test_gdb.py issue: |
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 992bee2. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 11 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
See #45619.
What changes are included in this PR?
Refactor using f-string instead of
string.format. But do not use f-string for following case,string.formatallows passing parameters, making the code more reusable.arrow/python/pyarrow/parquet/core.py
Lines 1624 to 1695 in 0fbf982
Are these changes tested?
Via CI.
Are there any user-facing changes?
No.
string.format#45619