astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
33.38k stars 1.11k forks source link

[`ruff`] Formatting hex codes changes output with f-string debug #14766

Open MeGaGiGaGon opened 11 hours ago

MeGaGiGaGon commented 11 hours ago

I had this idea while reading https://github.com/psf/black/issues/4522 when @MichaReiser said ruff had already stabilized hex code formatting.

I don't actively use ruff/am not familiar with it, but I assume that just like black formatting code should not have an observable runtime effect.

playground link formatting f"{r'\xFF'=}" gives f"{r'\xff'=}"

>>> f"{r"\xFF"=}"
'r"ÿ"=\'\\\\xFF\''
>>> f"{r"\xff"=}"
'r"ÿ"=\'\\\\xff\''
MichaReiser commented 11 hours ago

Oh that's a nice find!

Funny enough, this is fixed in the new preview style playground