Skip to content

UP031 (printf-string-formatting) difference between Ruff and pyupgrade #8107

Closed
@tdulcet

Description

@tdulcet

I ran Ruff on medium sized project and then pyupgrade. Ruff missed one UP031 autofix that pyupgrade fixed. Both Ruff and pyupgrade missed 96 UP031 (a known problem) and 23 UP032 (a few of these may be caused by #8106).

Ruff command:

ruff --target-version py310 --select UP --line-length 320 --unsafe-fixes --fix .

pyupgrade command:

pyupgrade --py310-plus **/*.py

Diff:

-       path = "%s-%s-%s.pem" % (
+       path = "{}-{}-{}.pem".format(
		safe_domain_name(cn), # common name, which should be filename safe because it is IDNA-encoded, but in case of a malformed cert make sure it's ok to use as a filename
		cert.not_valid_after.date().isoformat().replace("-", ""), # expiration date
		hexlify(cert.fingerprint(hashes.SHA256())).decode("ascii")[0:8], # fingerprint prefix
		)

(There were some additional differences due to Ruff not supporting the newer pyupgrade rules.)

Ruff version:

ruff 0.1.1

Metadata

Metadata

Assignees

Labels

fixesRelated to suggested fixes for violations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions