ruff
6159a8e5 - [`pyupgrade`] Generate diagnostic for all valid f-string conversions regardless of line-length (`UP032`) (#10238)

Commit
1 year ago
[`pyupgrade`] Generate diagnostic for all valid f-string conversions regardless of line-length (`UP032`) (#10238) ## Summary Fixes https://github.com/astral-sh/ruff/issues/10235 This PR changes `UP032` to flag all `"".format` calls that can technically be rewritten to an f-string, even if rewritting it to an fstring, at least automatically, exceeds the line length (or increases the amount by which it goes over the line length). I looked at the Git history to understand whether the check prevents some false positives (reported by an issue), but i haven't found a compelling reason to limit the rule to only flag format calls that stay in the line length limit: * https://github.com/astral-sh/ruff/pull/7818 Changed the heuristic to determine if the fix fits to address https://github.com/astral-sh/ruff/discussions/7810 * https://github.com/astral-sh/ruff/pull/1905 first version of the rule I did take a look at pyupgrade and couldn't find a similar check, at least not in the rule code (maybe it's checked somewhere else?) https://github.com/asottile/pyupgrade/blob/main/pyupgrade/_plugins/fstrings.py ## Breaking Change? This could be seen as a breaking change according to ruff's [versioning policy](https://docs.astral.sh/ruff/versioning/): > The behavior of a stable rule is changed * The scope of a stable rule is significantly increased * The intent of the rule changes * Does not include bug fixes that follow the original intent of the rule It does increase the scope of the rule, but it is in the original intent of the rule (so it's not). ## Test Plan See changed test output
Author
Parents
Loading