Skip to content

Apply ruff fixes and black formatting - #63

Draft
asg017 wants to merge 2 commits into
mainfrom
otel/00-lint
Draft

asg017 wants to merge 2 commits into
mainfrom
otel/00-lint

Conversation

@asg017

@asg017 asg017 commented Sep 28, 2026 •

Copy link
Copy Markdown
🤖 Claude-generated PR description

First PR in a stack that adds OpenTelemetry support. This one gets ruff check . and ruff format --check . passing, pins that tooling in the repo, and runs it in CI, so every later commit in the stack is lint-clean. It should not change behaviour.

Stack: lint (this PR) → 1.0a41 compatibility (#64) → supervised background tasks (#65) → empty jobs (#66) → telemetry (#67)

Changes

  • Safe ruff --fix fixes: .format() → f-strings, List/Optional/Union/Tuple → list / X | None / tuple (the project requires Python ≥ 3.10), import sorting, and removing unused imports (secrets, datasette.permissions.PermissionSQL).
  • Implicit Optional made explicit. The visible case is actor_id: str | None = None on Enrichment.enrich_batch / enqueue, which is an annotation-only change.
  • list(genexpr) → list comprehension in the example enrichments.
  • Removed the shebang and coding line from docs/conf.py.
  • black reformat (commit 1), then switched from black to ruff format (commit 2):
    • The dev group now pins ruff==0.16.9 and drops black. The lint rules are ruff's defaults, which change between releases, so the pin makes them reproducible.
    • Added a [tool.ruff] section.
    • Added a lint CI job that runs ruff check . and ruff format --check ..
    • Updated the Justfile recipes.
    • ruff format also formats the Python examples in docs/developing.md.
  • # noqa where the fix would change behaviour:
    • DTZ001: the naive JAN_1_2025_EPOCH datetime
    • RUF012: the Enrichment._subclasses registry
    • BLE001: the job loop's except Exception
    • TRY002: a test enrichment

Testing

  • ruff check . and ruff format --check .: clean.
  • pytest: 14 failed / 6 passed. That's the same 14 failures as main: main is already broken against Datasette 1.0a41 (CSRF tokens were removed, and the action-menu markup changed). The next PR in the stack fixes them.

🤖 Generated with Claude Code

noqa (behaviour-preserving): DTZ001 naive epoch datetime, RUF012 public
_subclasses registry, BLE001 job-loop error logging, TRY002 test enrichment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Pin ruff so its default rule set is reproducible.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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