Skip to content

Ruff precommit#235

Open
paigewilliams wants to merge 10 commits intodevelopfrom
ruff-precommit
Open

Ruff precommit#235
paigewilliams wants to merge 10 commits intodevelopfrom
ruff-precommit

Conversation

@paigewilliams
Copy link
Collaborator

adds a pre-commit hook to run ruff check and ruff format

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a pre-commit configuration to run Ruff linting and formatting locally before commits, aligning local developer workflow with the repo’s existing Ruff setup.

Changes:

  • Add .pre-commit-config.yaml with Ruff hooks (ruff-check with --fix, and ruff-format).
  • Add pre-commit to TEKDB/requirements.txt (and normalize the existing ruff entry).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
TEKDB/requirements.txt Adds pre-commit (and adjusts the ruff entry) so the tooling is installed via the main requirements set.
.pre-commit-config.yaml Introduces pre-commit hooks to run Ruff linting (with autofix) and formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +40
#pre-commit
pre-commit No newline at end of file
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit is being added to TEKDB/requirements.txt, which is installed in the production Docker image and used by update/provisioning scripts. This makes a dev-only tool part of the runtime dependency set and increases image size/attack surface unnecessarily. Consider moving pre-commit (and other lint/format tooling) into a separate dev requirements file (e.g., requirements_dev.txt) or an optional extra, and keep production installs on runtime-only dependencies.

Suggested change
#pre-commit
pre-commit
#pre-commit

Copilot uses AI. Check for mistakes.
whitenoise>=6.0.0,<7.0.0
# FORMATTING AND LINTING
ruff No newline at end of file
ruff
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are now two separate sources of truth for Ruff: CI installs and runs ruff from TEKDB/requirements.txt (currently unpinned), while pre-commit will run the Ruff version pinned by the hook rev. This can lead to developers auto-fixing/formatting with one Ruff version and then failing CI with another. Consider pinning ruff to a specific version in requirements.txt (ideally matching the pre-commit rev), or switching CI to run pre-commit run --all-files so both environments use the same pinned hook versions.

Suggested change
ruff
ruff==0.6.9

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +8
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.5
hooks:
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format No newline at end of file
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ruff version used by this pre-commit hook is pinned via rev, but CI currently runs ruff check from the version installed via TEKDB/requirements.txt. If these drift, developers may get different fixes/formatting locally than what CI expects. Consider aligning the versions by pinning ruff in requirements.txt to the same version as the hook (or updating CI to run pre-commit run --all-files).

Suggested change
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.5
hooks:
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
- id: ruff-check
name: ruff-check
entry: ruff
language: system
types: [python]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
name: ruff-format
entry: ruff
language: system
types: [python]
args: [ format ]

Copilot uses AI. Check for mistakes.
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.

2 participants