Repository navigation
build(format): ruff formatting and import order, checked in CI and pre-commit (#324) - #441
Open
amar-python wants to merge 6 commits into
Open
amar-python wants to merge 6 commits into
amar-python wants to merge 6 commits into
Conversation
…d in CI and pre-commit (#324) ruff formats (black's style, 120 columns, the flake8 line length) and orders imports, over .py files only. flake8 stays the lint. scripts/lint.sh, which the free-tier job runs, now also checks formatting and import order; `make format` rewrites. pre-commit gains the ruff-check and ruff-format hooks, at the version requirements-dev.lock installs. Made ready for the formatting commit that follows, so that commit changes layout only: - flake8 ignores E203 (whitespace before ':'), in .flake8 and scripts/lint.sh alike. It is incompatible with black-style slices such as x[a + 1 :], as flake8's own documentation says. - Two tests no longer depend on where a line breaks: an f-string's dict comprehension moved into a variable, and a lambda carrying '# noqa: E731' became a def. The formatter would have split the noqa onto another line. csv_loader/ is excluded until #431-#435 merge, so those PRs do not all conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011T6WqmGuQidunwiFfwKeBs
Mechanical: `make format` (ruff 0.17.6, pyproject.toml [tool.ruff]) over every tracked .py file except csv_loader/. Nothing else changed. Each file's syntax tree is the same before and after, apart from the order and grouping of its imports. The one exception is a module docstring's indentation in tests/unit/test_config.py, and nothing reads that docstring. Listed in .git-blame-ignore-revs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011T6WqmGuQidunwiFfwKeBs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011T6WqmGuQidunwiFfwKeBs
…ines (#324, #330) Formatting spread these over more lines, so tests/unit/test_function_length.py (#330's limit) failed: _do_upload 109, store_upload 85, effective_rows 84, import_upload 84, upload_dynamic 83. Each now calls helpers, and the statements run in the same order as before: - dynamic_loader: _lost_race and _database_error (upload_dynamic's two error responses); _prepare_version (lock, versions, types, table), _cast_and_log and _flag_earlier_versions (_do_upload's steps) - originals: _store_row_flags - staged_import: _validate_row (effective_rows' per-row check); _refuse_unless_importable and _audit_import (import_upload) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011T6WqmGuQidunwiFfwKeBs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011T6WqmGuQidunwiFfwKeBs
Owner
Author
|
The
Generated by Claude Code |
amar-python
marked this pull request as ready for review
November 28, 2026 05:31
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.
Refs #324. That issue is closed, but its formatter criterion ("Adopt ruff (lint + format), or black + isort, with a one-off formatting commit recorded in
.git-blame-ignore-revs") was never done..pre-commit-config.yamlonmainsaid so: "No formatter yet". This PR does it.What changes
max-line-length. Configured inpyproject.toml[tool.ruff]..pyfiles only, because ruff would also reformat the Python examples indocs/*.md.select = ["I"]) only. flake8 stays the lint, with the same options in.flake8andscripts/lint.sh, plus one addition (below).scripts/lint.sh, which thefree-tierjob already runs, now also runsruff format --checkandruff check. It never rewrites anything. No workflow file changed.make formatrewrites. pre-commit gains theruff-check --fixandruff-formathooks, at the versionrequirements-dev.lockinstalls, which a test keeps equal.ruff>=0.17.6inrequirements-dev.txt. Re-locked withscripts/lock_requirements.sh: the only new lock entry isruff==0.17.6..git-blame-ignore-revslists the formatting commit. GitHub reads it already; README gives the one-linegit configfor local blame.csv_loader/extend-exclude), as you chose, so #431–#435 don't all conflict. Format it once they merge, then delete that line. A test fails if the excluded folder disappears.Commits (review them one at a time)
df7fcebconfig. The changes that let the formatting commit be purely mechanical::), in.flake8andlint.shalike. black-style slices likex[a + 1 :]trip it, and flake8's own docs call E203 incompatible with black.# isort: splitin 8 files. ruff's import sort treats blank lines between import groups as nothing. Without the marker it movedimport api_clientabovefrom tests.unit import streamlit_harness, which putsstreamlit_app/on the path, and 7 test modules failed to import. The 8th ise2e/conftest.py, sopreflightkeeps its place.# nosec B608: the SQL went into a variable (migration 0006).# noqa: E731became adef.20cd32ethe formatting. Output ofmake formatonly: 216 files.1c92306.git-blame-ignore-revs.51b5e31five functions split (dynamic_loader,originals,staged_import). The formatter spread them past [SE-09][Medium] Loader functions too long, with duplicated logic (SRP/DRY): _do_upload 274 lines, upload_te 240 #330's 80-line limit;_do_uploadwent from 75 to 109 lines. Each one now calls named helpers, and its statements run in the same order. Details are in the commit message.main, which brought in only the dependency pins and a plan document.Evidence (local, PostgreSQL 16, all four environments deployed as CI does)
tests/unit/test_config.py, where ruff re-indented the module docstring; nothing reads that docstring.streamlit_harnessimports ande2e/conftest.py, and those are now held in place by# isort: split.pytest tests/ -m "not accessibility"→ 1881 passed, 0 failed, 0 skipped. That includes refactor(loaders): split the loaders behind shared helpers, no function over 80 lines (#330) #414's golden test, which compares 28 upload responses byte for byte; it shows the function splits changed nothing either.make coverage, after mergingmain): passes.dynamic_loader.py91.9 %,te_loader.py97.9 %,load_common.py100 %.api/95.9 %,streamlit_app/97.4 %.scripts/lint.shclean (flake8, bandit, ruff), and mypy clean (53 files).tests/unit/test_reproducible_builds.py36 passed after the merge.tests/unit/test_tool_config.py(they fail when one copy of a setting drifts from another):I, usesforce-exclude, and includes only*.py; the format hook skips Markdown.lint.shruns both ruff checks..git-blame-ignore-revslists only full commit ids.For open PRs
Any open PR that changes Python files outside
csv_loader/will conflict on layout after this merges. The fix is to mergemaininto it and runmake formaton its own changes.Generated by Claude Code