Apply linting to entire codebase & add CI workflow to check linting by deruyter92 · Pull Request #3216 · DeepLabCut/DeepLabCut
This was referenced
Feb 23, 20263 tasks
Bump pyproject-fmt to v2.18.1 and ruff-pre-commit to v0.15.6. Add docformatter (v1.7.7) with formatting args (--wrap-summaries/--wrap-descriptions=88, --in-place, --black). Keep ruff hooks (format + check) and existing validate-pyproject/trailing-whitespace hooks.
Introduce tools/ruff_report.py: a CLI script that runs `ruff` on given paths (using `--output-format=json --exit-zero`), parses the JSON results, and generates a readable Markdown report. The report groups issues by rule and file, includes a summary table, suggested triage order, table of contents, per-rule sections with detailed issue tables, and VS Code "Quick open" commands. The script also embeds short RULE_NOTES for common codes, accepts paths (default `.`) and `--output` (default `ruff-report.md`), and writes the generated Markdown to disk.
Add tools/trim_lines.py: a command-line helper that finds files with Ruff E501 violations and attempts to reduce them using autopep8, then normalizes formatting with Ruff. It scans paths via `ruff check --output-format=json`, supports batching (50 files), a configurable `--line-length` (default 88), and a `--check` dry-run mode. The script prints invoked commands and outputs, runs autopep8 with selected fixes, then runs `ruff --fix --unsafe-fixes` and `ruff format`. Requires ruff and autopep8.
Standardize docstring punctuation and formatting across modules, add stacklevel=2 to warnings.warn calls for clearer warning locations, and make zip/dict(zip()) usages more robust by passing strict=False where appropriate. Also include minor loop variable/name cleanups and CLI help text formatting fixes. These changes improve error tolerance when iterables differ in length, produce more helpful warning tracebacks, and tidy user-facing documentation strings.
Delete the generated ruff-report.md (large auto-generated lint report) and add tmp/* to .gitignore to avoid committing tool output. Also include an update to tools/ruff_report.py (script changes) alongside the cleanup.
Rework deeplabcut package initialization: use relative imports, add a logger and robust DEBUG env parsing, and replace eager imports of optional GUI/PyTorch features with a lazy-loading mechanism. Optional public names (GUI and transformer_reID) are resolved on first access via __getattr__ (with clear error messages when dependencies are missing) and cached for subsequent use; __dir__ and a consolidated __all__ improve discoverability. Removes previous noisy prints and light-mode fallbacks in favor of structured logging and explicit public API grouping.
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