Skip to content

Update pre-commit & linting configuration#3215

Merged
deruyter92 merged 12 commits intoDeepLabCut:jaap/reformat_codebasefrom
deruyter92:jaap/update_linting_precommit
Mar 20, 2026
Merged

Update pre-commit & linting configuration#3215
deruyter92 merged 12 commits intoDeepLabCut:jaap/reformat_codebasefrom
deruyter92:jaap/update_linting_precommit

Conversation

@deruyter92
Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 commented Feb 23, 2026

This PR is part of the task described in issue #3217

Motivation:

Pre-commit hooks and proper linting has not been applied consistently in existing codebase. Following DeepLabCut/DeepLabCut-live#165, it would be great to introduce a modern and consistent linting configuration again, after reformatting the codebase.

Order of merging:

Current ruleset

E — Pycodestyle Errors:
Enforces basic style guidelines such as spacing, indentation, and line formatting, helping maintain a consistent style.
F — Pyflakes Errors:
Helps catch code issues like unused variables, undefined names, and logical mistakes that could lead to runtime errors.
B — Bugbear Rules:
Highlights code patterns that are likely to cause bugs or unexpected behavior (e.g., mutable defaults, overly broad exceptions), improving reliability and safety.
I — Import Sorting (isort):
Ensures imports follow a consistent, predictable order, reducing merge conflicts and making dependencies easier to scan.
UP — pyupgrade Rules:
Automatically upgrades syntax to modern Python features (aligned with Python 3.10), simplifying code and reducing technical debt.

Ignored rule(s):

E741 — Ambiguous Variable Names:
Ignored to avoid false positives when short variable names (like l, I, O) are acceptable or intentional.

Scope

(Copies the changes in DeepLabCut/DeepLabCut-live#165, by @C-Achard)

  • Bump pre-commit hooks to v6.0.0
  • Move to Ruff (a fast and modern formatting tool) from black+isort only
    • Ruff is intended as a drop-in replacement
    • Ruff is faster than combining black+isort
  • Add the following linting rules to pyproject.toml:
lint.select = ["E", "F", "B", "I", "UP"]
lint.ignore = ["E741"]
target-version = "py310"
fix = true
line-length = 120

Copy link
Copy Markdown
Collaborator

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

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

Looks good, thanks !

@deruyter92 deruyter92 added the enhancement New feature or request label Feb 28, 2026
@deruyter92 deruyter92 self-assigned this Feb 28, 2026
@C-Achard C-Achard added the CI Related to CI/CD jobs and automated testing label Mar 3, 2026
@C-Achard C-Achard marked this pull request as ready for review March 5, 2026 13:54
@C-Achard C-Achard requested review from AlexEMG and MMathisLab March 6, 2026 10:39
@deruyter92 deruyter92 changed the base branch from main to jaap/reformat_codebase March 20, 2026 12:26
@deruyter92 deruyter92 merged commit 4fd852d into DeepLabCut:jaap/reformat_codebase Mar 20, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Related to CI/CD jobs and automated testing enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task: Fix linting & and pre-commit-hooks and add to CI workflow

3 participants