Adopt ruff 0.16's default rule set and fix the violations - #106
Open
maxdymond wants to merge 1 commit into
Open
Conversation
Revert "Pin ruff lint rule selection explicitly" (acec0dee) so ruff.toml
uses extend-select again, taking ruff 0.16's expanded defaults rather
than freezing the rule set at 0.15's. Fix the 40 resulting violations.
Autofixed (29), all typing modernization:
UP006 Dict/List -> dict/list
UP045 Optional[X] -> X | None
UP035 deprecated typing imports
UP043 redundant default type args
By hand (11):
TRY004 azcmd: raise TypeError, not ValueError, from the isinstance
guards. No caller catches ValueError from these methods.
DTZ005 Use datetime.now().astimezone() so log filenames keep local
time rather than switching to UTC.
LOG015 Use a module logger instead of root logging.info.
PYI034 FuncApp.__enter__ returns Self, so the subclasses now type
correctly under a context manager.
EXE001 Drop the vestigial shebang from create_resources.py; it is
invoked via the create-resources console script, never
directly, so it needs no exec bit.
SIM115 noqa + comment at the two NamedTemporaryFile sites. The
delete=False handle deliberately outlives its scope so the
path can be built into; FuncApp.__exit__ unlinks it.
RUF100 Remove three stale noqa directives.
Also fixes a latent bug found while reviewing the TRY004 sites:
run_expect_list annotated its local as dict[str, Any] while returning
list[str]. Corrected to list[str].
The RUF100 autofix stripped the rationale comment explaining the broad
except in signing.load_private_key; restored as a plain comment.
Verified against the pinned ruff 0.16.2 (not the older ruff on PATH):
ruff check, ruff format --check, and mypy all clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #(commit
acec0dee, "Pin ruff lint rule selection explicitly") soruff.tomlusesextend-selectagain, taking ruff 0.16's expanded defaults rather than freezing the rule set at 0.15's — then fixes the 40 violations that surfaces.ruff.tomlis an exact revert; everything else is the fallout.Autofixed (29) — typing modernization
UP006Dict/List→dict/listUP045Optional[X]→X | NoneUP035typingimportsUP043By hand (11)
TRY004×2azcmd: raiseTypeError, notValueError, from theisinstanceguards. Checked first — no caller catchesValueErrorfrom these methods.DTZ005datetime.now().astimezone(), so log filenames keep local time rather than silently switching to UTC.LOG015logging.info.PYI034FuncApp.__enter__returnsSelf, soFuncAppZip/FuncAppBundlenow type correctly under a context manager.EXE001create_resources.py— it's invoked via thecreate-resourcesconsole script, never directly, so it doesn't need an exec bit.SIM115×2noqa+ comment at the twoNamedTemporaryFilesites. Thedelete=Falsehandle deliberately outlives its scope so the zip can be built into that path;FuncApp.__exit__unlinks it. A context manager would be wrong here.RUF100×3noqadirectives.Two things worth a look
run_expect_listannotated its local asdict[str, Any]while returninglist[str]— a copy-paste error. Corrected tolist[str].RUF100autofix silently ate a rationale. Removing the dead# noqa: BLE001also took the- pgpy raises a variety of errorsnote explaining the broadexcept Exceptioninsigning.load_private_key. Restored as a plain comment.Verification
Run against the pinned ruff 0.16.2, installed from PyPI — note the
ruffon my PATH was 0.15.20, which is why this looked clean locally before:ruff check— cleanruff format --check— cleanmypy— clean, 9 source filesTypeErrorpaths andcommon_loggingat runtimeCI has no test step, so there was no suite to run.
Not included
Setting
python_version = "3.13"under[tool.mypy]would pin mypy the same way this PR unpins ruff — without it, mypy infers the version from whichever interpreter it runs under, which makestyping.Selflook like an error in an editor using a pre-3.11 Python. Happy to add it here or separately.