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

Prefer f-strings instead of str.format #2164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WhyNotHugo
Copy link
Member

No user facing changes.

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

I wonder if pyupgrade could've handled this.

@@ -429,9 +429,9 @@ def get_best_match(self, ireq: InstallRequirement) -> InstallRequirement:

# Format the best match
log.debug(
Copy link
Member

Choose a reason for hiding this comment

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

Logging is supposed to pass params through dedicated arguments, though. Instead of pre-rendering strings before passing them into logging..

Copy link
Member Author

Choose a reason for hiding this comment

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

That's exactly what my change does.

Previously a pre-rendered string was being passed (one using .format()). Now dedicated arguments are passed.

@WhyNotHugo
Copy link
Member Author

WhyNotHugo commented Feb 19, 2025

I wonder if pyupgrade could've handled this.

Ruff's pyupgrade re-implementation does handle this. This PR and #2163 are groundwork for using ruff instead of flake8+pyupgrade, but can be merged independently.

@WhyNotHugo
Copy link
Member Author

Not sure about th CI failures. Rebased onto latest main.

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.

2 participants