Skip to content

Prefer f-strings instead of str.format #2164

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

Closed
wants to merge 1 commit into 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.

@sirosen
Copy link
Member

sirosen commented Jun 27, 2025

I think pyupgrade would, indeed, handle a couple of these and is a good idea (original implementation or ruff) regardless for the numerous other fixes it applies. But that's doesn't block this PR.

I've hit the GitHub rebase button since a lot of CI has been fixed significantly at this point.
I was hoping CI would be clean, but there still appear to be errors, which is disappointing.

@WhyNotHugo WhyNotHugo closed this by deleting the head repository Jun 30, 2025
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