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

chore: replace percent strings for logging #1448

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Venefilyn
Copy link
Member

This replaces logging with their best counterpart. Either normal logging
methods with arguments, or by utilizing .format()

Depends on #1431

@@ -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"
Copy link
Member

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.```

Copy link
Member Author

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

pre-commit-ci bot and others added 3 commits January 16, 2025 14:30
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.
@Venefilyn Venefilyn force-pushed the chore/percent-strings branch from bf0c24f to d78a11d Compare January 16, 2025 13:30
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.11%. Comparing base (f21f6cf) to head (d78a11d).

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           
Flag Coverage Δ
centos-linux-7 91.63% <75.00%> (ø)
centos-linux-8 92.49% <100.00%> (ø)
centos-linux-9 92.61% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Venefilyn Venefilyn requested a review from bocekm January 20, 2025 12:53
@Venefilyn Venefilyn added skip/changelog If it should be excluded from changelog or Release notes. Such as infra, reverted PRs, etc. tests/sanity PR ready to run the sanity test suit. Equivalent to `/packit test --labels sanity`. kind/refactor labels Jan 20, 2025
@has-bot
Copy link
Member

has-bot commented Jan 20, 2025

/packit test --labels sanity


Comment generated by an automation.

@Venefilyn
Copy link
Member Author

/packit test --labels sanity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/refactor skip/changelog If it should be excluded from changelog or Release notes. Such as infra, reverted PRs, etc. tests/sanity PR ready to run the sanity test suit. Equivalent to `/packit test --labels sanity`.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants