Repository navigation
build: replace black, isort, flake8 and pydocstyle with ruff - #337
Merged
Merged
Conversation
nikbpetrov
force-pushed
the
ruff-tooling
branch
from
October 25, 2026 17:26
5ed45f3 to
3ecd529
Compare
Closed
nikbpetrov
force-pushed
the
ruff-tooling
branch
from
October 29, 2026 09:28
3ecd529 to
879624f
Compare
Member
|
3 issues found by claude: |
Swap the four lint/format tools for a single exact-pinned `ruff`, configured in `pyproject.toml` with a ruleset that mirrors the previous setup: `E`/`W`/`F`/`B`/`I`/`D` with `E203`, `E701` and bugbear's opt-in `B9xx` ignored, pycodestyle `max-line-length = 110` standing in for `B950`, `pep257` docstrings, and tests exempt from `D` as they were under `pydocstyle`. `setup.cfg` is gone. Markdown files are excluded from `ruff format` so fenced code blocks stay untouched, as before. `make lint` keeps its name and its `MAKE_LINT_ERROR_OUT=1` check mode, so the CI workflow is unchanged. In fix mode it runs `ruff check --fix --exit-zero`, then `ruff format`, then `ruff check`: fixes before formatting, as ruff recommends, and `--exit-zero` so that a finding ruff cannot fix (a long line) does not stop `make` before the formatter has had its turn to wrap it; the last `ruff check` reports what is left. Code changes are mechanical: * `# noqa: B950` becomes `# noqa: E501`, or is dropped where ruff reports the directive unused. The 46 in `sources/_metadata.py` were leftovers on closing parentheses of lines black had already wrapped. `# flake8: noqa: B950` used to exempt the whole file from flake8; the two files that still need it (`sources/fred_questions.py`, `sources/wikipedia.py`, long ID and series tables) get a `per-file-ignores` entry for `E501` in `pyproject.toml` instead and are otherwise clean. * `# noqa: E402` after `sys.path` edits is dropped because ruff allows imports there. * The `ruff format` pass, including the PEP 758 `except A, B:` form from `target-version = "py314"`. Closes forecastingresearch#121
nikbpetrov
force-pushed
the
ruff-tooling
branch
from
October 29, 2026 15:28
879624f to
40fda14
Compare
Collaborator
Author
(applies only to docs, not to code, which still uses |
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.
On top of #340
Only thing to pay attention to, @houtanb , is the jupyter notebooks - minor formatting changes.
===
Swap the four lint/format tools for a single exact-pinned
ruff, configured inpyproject.tomlwith a ruleset that mirrors the previous setup:E/W/F/B/I/DwithE203,E701and bugbear's opt-inB9xxignored, pycodestylemax-line-length = 110standing in forB950,pep257docstrings, and tests exempt fromDas they were underpydocstyle.setup.cfgis gone. Markdown files are excluded fromruff formatso fenced code blocks stay untouched, as before.make lintkeeps its name and itsMAKE_LINT_ERROR_OUT=1check mode, so the CI workflow is unchanged.ruff check --fixruns beforeruff format, as ruff recommends.Code changes are mechanical:
# noqa: B950becomes# noqa: E501, or is dropped where ruff reports the directive unused. The 46 insources/_metadata.pywere leftovers on closing parentheses of lines black had already wrapped.# flake8: noqa: B950used to exempt the whole file from flake8;# ruff: noqa: E501only exempts line length, and those files are otherwise clean.# noqa: E402aftersys.pathedits is dropped because ruff allows imports there.ruff formatpass, including the PEP 758except A, B:form fromtarget-version = "py314".AST is byte-identical, so no parity job runs are needed.
Closes #121