Adopt ruff 0.16's default ruleset - #118
Open
WillKoehrsen wants to merge 2 commits into
Open
Conversation
ruff 0.16 replaced its narrow legacy default with a broad curated default set, so this drops the hand-maintained select in favour of extend-select. The project now inherits the default rules and only names the families it needs on top: pyflakes and pycodestyle in full, quotes, and import sorting. Three families are ignored with reasons (declarative class attributes, nested with blocks, and vanilla exception classes). The rest are fixed. Two of the flagged datetime calls are deliberately local rather than UTC and now say so. get_daily_peak_report documents its default market_date as the caller's current date, and process_date treats a literal "today" the same way; only the calendar date survives the strftime in both, so switching to UTC would shift the default market day for callers west of UTC. The pytest.raises(Exception) assertions match what the client actually raises, which is a bare Exception for API errors. Narrowing them means introducing a custom exception hierarchy, which is a public API change and is deferred with TRY002. The rest is mechanical: dict() and set() literals, merged isinstance calls, unnecessary range starts, and dropped unused noqa directives. Note that ruff 0.16's formatter also reformats Python inside Markdown fences. Neither `make lint` nor the pre-commit hook asks it to, so the README and CHANGELOG examples are deliberately left alone. Verified: ruff check and format are clean over the package and the whole repo, pyright reports no errors, the package imports, and all 153 tests collect. The suite itself calls the live API, so it needs a key to run and was not executed.
CI runs `make lint`, which resolves ruff through uv.lock, while the pre-commit hook resolves its own rev. A compatible-release pin lets the lockfile move to 0.16.x while the hook rev stays put, so both are now pinned to the same exact version and the comment says why.
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.
Bumps ruff from the
>=0.5.0,<0.6pin to~=0.16and switches from a hand maintainedselecttoextend-select, so the project inherits ruff's new default rule set instead of pinning 5 rules and missing future additions.The new defaults report 28 findings here. Three families are ignored with stated reasons and the remaining 9 are fixed.
Two datetime calls stay local on purpose
DTZflags both, but UTC would be wrong:get_daily_peak_reportdocuments its defaultmarket_dateas the caller's current date.process_datehandles a literal"today"the same way.Only the calendar date survives the
strftimein both, so switching to UTC would shift the default market day for anyone west of UTC. Both now carry a comment saying why they are local.pytest.raises(Exception) left broad
B017is correct that these are blind, but the client raises a bareExceptionfor API errors, so the assertions match reality. Narrowing them means adding a custom exception hierarchy, which is a public API change, so it is deferred along withTRY002.Ignored families
RUF012SIM117withblocks read better than one merged statementTRY002Everything else
Mechanical:
dict()andset()calls to literals, mergedisinstancecalls, unnecessaryrangestarts, an f string conversion, and unusednoqadirectives. Notebook examples pick up the same literal cleanups since the pre commit hook lints Jupyter files.One upgrade note: ruff 0.16's formatter also reformats Python inside Markdown fences. Neither
make lintnor the pre-commit hook asks it to, so the README and CHANGELOG examples are deliberately untouched.How to validate
make lint, plusuv run ruff check .to cover the whole repo including notebooksuv run pyrightuv run pre-commit run --all-filesmake test, which CI also runs on Python 3.10 through 3.13Nothing here changes runtime behaviour. The only edits on executable paths are the two
noqacomments above and literal rewrites that evaluate identically.