-
Notifications
You must be signed in to change notification settings - Fork 87
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
chore: replace percent strings for logging #1448
base: main
Are you sure you want to change the base?
Conversation
@@ -318,8 +318,7 @@ def format_pkg_info(pkgs, disable_repos=None): | |||
max_nvra_length = max(len(nvra) for nvra in package_info) | |||
|
|||
header = ( | |||
"%-*s %-*s %s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got this from Grok AI since it's been long since I wrote that code:
%-*s in print("%-*s" % (width, "text")) is a format specifier where: * means the width of the field is given by the first argument in the tuple (width in this case). - means left-align the text within that width. s means it's formatting a string.```
The format()
replacement would look like print("{:<{}}".format("text", width))
.
{:<{}} means: < aligns the text to the left. {} specifies the field width.```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked on my own using https://pyformat.info/ and found a solution that looks a bit better
updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.3 → v0.8.2](astral-sh/ruff-pre-commit@v0.7.3...v0.8.2) - [github.com/teemtee/tmt.git: 1.38.0 → 1.39.0](https://github.com/teemtee/tmt.git/compare/1.38.0...1.39.0) - [github.com/jendrikseipp/vulture: v2.13 → v2.14](jendrikseipp/vulture@v2.13...v2.14)
This replaces logging with their best counterpart. Either normal logging methods with arguments, or by utilizing `.format()`
This changes `%-*s %-*s %s` %-string to their format counterpart `%-*s` = left-padded with next %-parameter indicating substring length or precision length.
bf0c24f
to
d78a11d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1448 +/- ##
=======================================
Coverage 96.11% 96.11%
=======================================
Files 72 72
Lines 5176 5176
Branches 895 895
=======================================
Hits 4975 4975
Misses 119 119
Partials 82 82
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/packit test --labels sanity |
This replaces logging with their best counterpart. Either normal logging
methods with arguments, or by utilizing
.format()
Depends on #1431