-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ruff
] Recognize more expressions (RUF027
)
#15247
base: main
Are you sure you want to change the base?
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF027 | 29 | 29 | 0 | 0 | 0 |
The true-positive-turned-false-negative: raise ValueError(
"Scale {scale!r} is not in the allowed scales {sorted(self.SCALES)}"
) #9849 has a bit more context on why strings whose placeholders' names are the same as that of built-ins are ignored. This interacted poorly with the new logic; in addition, it fails to recognize dunder names: print('{__path__}') # Currently a false negative |
The new changes introduced a few true positives, most notably: params_path.write_text(dedent(r"""
...
generated_parameters = {
__params__
}
""").replace("__params__", reindent("".join(params), 1))) geodetic_base_doc = """{__doc__}
...
"""
@format_doc(geodetic_base_doc)
class BaseGeodeticRepresentation(BaseRepresentation): ... The former is embedded code, while the latter is dynamically interpolated. These cannot be detected reliably in the first place, so I think the false positives are acceptable. |
I haven't looked at this PR yet, but note that RUF027 already has too many false positives for us to consider stabilising it. I definitely don't think we should be making changes that introduce new false positives here, honestly |
If so, this PR might as well be closed, as this is now considered an error: python_major_minor_version = run_command(
[
str(PYTHON_BIN_PATH),
"-c",
"import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')",
],
).stdout.strip() |
It does find some new actual violations but we should look into if we can find a way to reduce the false positives. |
Summary
Resolves #15227.
Test Plan
cargo nextest run
andcargo insta test
.