Skip to content

chore: replace Codacy with in-repo tooling - #151

Merged
monodera merged 12 commits into
mainfrom
chore/replace-codacy-tooling
Aug 5, 2026
Merged

chore: replace Codacy with in-repo tooling#151
monodera merged 12 commits into
mainfrom
chore/replace-codacy-tooling

Conversation

@monodera

@monodera monodera commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The repository was removed from the Codacy service, so .github/workflows/codacy.yml is dead — CODACY_PROJECT_TOKEN is invalid and it would fail on every run. This replaces it with equivalent checks whose configuration lives in the repository, where it is visible and version-controlled rather than in a web UI.

Note on security scanning: CodeQL has been disabled (disabled_manually, since 2026-05-22) independently of this change, well before this work started. So removing Codacy does not, in itself, take away code-scanning coverage that CodeQL was providing — there wasn't any at the time of this PR. Re-enabling CodeQL is a separate, one-click decision under Settings → Actions → Workflows, not something this PR does.

What changed

Commit
eb575a8 Remove the dead Codacy workflow
361c05d Apply black to 6 files that had drifted out of compliance
86a72da Expand ruff from an inert config to E, W, F, I, B, C4, UP
268ff34 Resolve the 11 findings that surfaced
6fdfeb8 Add the Lint workflow and pre-commit hooks
1bdd471 Mechanical whitespace / end-of-file sweep, 14 files
2eb9072, a5d860c Review follow-ups

Formatting is isolated in its own commits so the mechanical diffs do not obscure the substantive changes.

Two ruff configuration defects fixed along the way

  • target-version said py312 while requires-python allows 3.11. With UP rules enabled, ruff was free to rewrite code into 3.12-only syntax and break the declared 3.11 support.
  • The setuptools-scm-generated _version.py was being linted despite being gitignored and absent from a fresh checkout, so the linted file set differed between local and CI.

Two deliberate suppressions

  • F401 on models/proposal.py. partner is imported defensively. models/__init__.py already imports it first, so this line is not what registers the model today — configure_mappers() succeeds without it and the test suite returns an identical result either way. It is kept so the string-based ForeignKey("partner.partner_id") keeps resolving if that import order is ever changed. A blanket ruff check --fix would have deleted it, which is why the pre-commit hook is check-only (below).
  • B006 on cli/cli_main.py. The standard Typer Annotated idiom; Typer does not mutate the default, and converting it would change the --help output.

Notes for review

  • This makes a durable change to what future contributions must satisfy. F401, F841 and B008 move from globally ignored to enforced. C901 stays off (C90 is not selected) — the codebase currently has 5 latent mccabe violations in utils.py that would surface if anyone adds it.
  • alembic/ is deliberately unlinted and unformatted. The exclusion lives in pyproject.toml for both ruff and black, not only in the workflow's arguments, so editor extensions agree with CI and cannot rewrite historical migrations.
  • The pre-commit ruff hook does not use --fix, matching CI's check-only behaviour. Because F401 is auto-fixable and this package uses deliberate registration-only imports, a rewriting hook could silently delete one and surface it later as a NoReferencedTableError.
  • check-yaml excludes mkdocs.yml, whose mkdocs-material !!python/name: tags yaml.safe_load cannot construct. args: [--unsafe] was rejected because it would weaken the check for every other YAML file, including the workflows added here.

Verified locally

ruff check . clean · black --check . clean · pre-commit run --all-files all 7 hooks pass, idempotent across two runs · pytest tests/ -v with Docker: 29 passed, 1 skipped.

Not included

Enabling Dependabot alerts, secret scanning and push protection — those are settings changes requiring admin rights, not code changes. They have since been enabled directly on the repository, independently of this PR.

🤖 Generated with Claude Code

monodera and others added 12 commits August 4, 2026 16:00
The repository is no longer registered with Codacy, so
CODACY_PROJECT_TOKEN is invalid and this workflow would fail on every
run. CodeQL continues to upload SARIF to GitHub code scanning, so
security results are not lost.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The tree had drifted out of black compliance. Isolated in its own commit
so the mechanical diff does not obscure the substantive changes that
follow.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
select was commented out, leaving ruff's defaults with F401, F841, E501,
B008 and C901 further suppressed, so ruff reported no findings at all.

Also fixes two defects: target-version said py312 while requires-python
allows 3.11, which would let UP rules emit 3.12-only syntax; and the
setuptools-scm-generated _version.py was being linted despite being
gitignored and absent from a fresh checkout.

Findings are resolved in the following commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Nine findings auto-fixed by `ruff check --fix` (import sorting, PEP
585/604 annotations, useless object inheritance, f-string conversion,
and the typing import cleanup, which ruff performed itself as a
cascading fix once List/Optional became unused). C416 fixed by hand
(ruff's unsafe-fix category).

Two findings are suppressed rather than fixed:

- F401 on models/proposal.py: `partner` is imported defensively.
  models/__init__.py already imports partner six lines before proposal
  is imported, so proposal.py's own import is not what registers the
  model today; configure_mappers() succeeds without it, and the test
  suite currently passes identically with or without this line, so it
  does not discriminate between the two states. The import is kept so
  that the string-based ForeignKey("partner.partner_id") keeps
  resolving even if __init__.py's import order is ever changed.
- B006 on cli/cli_main.py: the mutable default is the standard Typer
  Annotated idiom and Typer does not mutate it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Replaces the repository-external Codacy checks with equivalents whose
configuration lives in the repository. ruff findings surface as inline PR
annotations via --output-format=github.

Kept separate from test_database.yml so lint results do not wait on
Postgres startup and ER diagram generation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mechanical sweep by the pre-commit hooks added in the preceding
commit. Whitespace and final-newline changes only; no file's content
is otherwise altered.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Exclude alembic in the ruff config itself, not just in the runners'
  arguments, so editors and a bare `ruff check .` agree with CI. The
  migrations are historical records and are deliberately unlinted.
- Drop `--fix` from the pre-commit ruff hook. F401 is auto-fixable, and
  this package uses deliberate registration-only imports; a hook that
  rewrites them can silently delete one and surface it later as a
  mapper-configuration failure. The hook now matches CI's check-only
  behaviour.
- Rename the hook to its current id, `ruff-check`; `ruff` is a legacy
  alias that a future rev bump may drop.
- Scope the whitespace hooks and the large-file check away from
  examples/data/uploader/, which holds multi-megabyte vendored fixtures.
- Correct the README's claim that passing the hooks implies CI will pass.
- Make black's exclusion of the generated _version.py explicit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The preceding commit moved the alembic exclusion into the ruff config so
editors and a bare `ruff check .` agree with CI. black had the same gap:
its config excluded only the generated _version.py, so an editor's black
extension with format-on-save would reformat historical migrations that
CI never inspects.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…to chore/replace-codacy-tooling

# Conflicts:
#	diagrams/erdiagram_targetdb_latest.pdf
#	docs/tbls/public.fluxstd.md
#	docs/tbls/public.sky.md
@monodera
monodera merged commit 5e7c4f6 into main Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant