Repair violations from Ruff 0.16's expanded defaults - #33
Conversation
Ref jaraco/skeleton#210. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
CI note: everything passes except Also worth noting: |
| list[filters.Tag] | None, typer.Option('--tag', '-t', parser=filters.Tag) | ||
| ] = None, | ||
| keyword: Annotated[ | ||
| list[filters.Keyword], | ||
| list[filters.Keyword] | None, | ||
| typer.Option('--keyword', '-k', parser=filters.Keyword), | ||
| ] = [], | ||
| ] = None, | ||
| *, | ||
| ctx: typer.Context, | ||
| ): | ||
| selectors = filters.Selectors(tag + keyword) | ||
| selectors = filters.Selectors(itertools.chain(tag or (), keyword or ())) |
There was a problem hiding this comment.
I'm not loving this change. The prior implementation had a simpler signature and usage. Is there a way we can continue to use degenerate sequences instead of a separate None type?
There was a problem hiding this comment.
Agreed — reverted to the original signature and tag + keyword body in 8aece41, with a # noqa: B006 on each default.
I did try to keep it lint-clean without the suppression, but typer boxes you in: = () works at runtime (typer replaces it with a list either way, verified) yet mypy rejects a tuple default against a list[...] annotation, and typer can't consume the annotations that would fix that — Sequence[str] raises RuntimeError: Type not yet supported, and tuple[str, ...] raises Type not yet supported: Ellipsis. So list[X] = [] is the only spelling that satisfies both typer and mypy.
The suppression is honest here: typer always supplies the option value, so the default is never bound, let alone mutated — the same reason the skeleton already ignores B008 globally for = typer.Option(...). If you'd rather not carry inline noqas, B006 could join B008 in the skeleton's ignore list on the same rationale; happy to make that change instead.
typer supplies the option values, so the empty lists are never mutated; suppress B006 rather than complicate the signature with None. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Ref jaraco/skeleton#210.
Ruff 0.16 broadened its built-in default rule set, and because
ruff.tomlusesextend-select, this project inherited 19 new violations. All are now repaired;ruff check .andruff format --check .are clean and the test suite (including mypy) passes.Changes
Mechanical / no behavior change
git.py:startswithcalled once with a tuple (PIE810);'...'.split()replaced with list literals here and inmigrate-config.py(SIM905);Project.tagsannotatedClassVar(RUF012);Project.__new__'s first parameter renamedself→cls(PLW0211).compiler.py: nestedwithstatements combined (SIM117). The blindexcept Exceptionis deliberate — the function's contract is to report any compile failure as a string — so it carries anoqaand a comment rather than a narrowed clause (BLE001).indent.py,migrate-config.py: unused unpacked variables renamed to_(RUF059).Behavior changes worth a look
init-azure.pyandmacos-build-python.pypasscheck=True: their steps are sequential and dependent (configure → make; create project → create endpoint → create pipeline), so continuing after a failure only produced a confusing second failure (PLW1510).git.py'sURLScheme.loadandcpython-sync.py's finalgit commitpasscheck=False, since a non-zero exit is an expected outcome for both (no configured substitutions; nothing to commit). Both are commented.projects-run.py: the= []typer defaults become| None = None, matching the style already inupdate-projects.py, with the two lists joined viaitertools.chain(B006). Verified that--tag/--keywordstill collect multiple values.github.py:Repo.get_public_key()becomes theRepo.public_keycached property (B019).functools.lru_cacheon a method kept everyRepoinstance alive for the process and shared one key across repos;cached_propertycaches per instance. This is the one API break — happy to keep the method name viajaraco.functools.method_cacheinstead if you'd rather not spend a major version on it.🤖 Generated with Claude Code