Skip to content

Add pre-commit configuration and improve code quality checks - #6

Merged
Ajimaru merged 2 commits into
mainfrom
chore/pre-commit-hooks
Dec 2, 2026
Merged

Ajimaru merged 2 commits into
mainfrom
chore/pre-commit-hooks

Conversation

@Ajimaru

@Ajimaru Ajimaru commented Dec 2, 2026

Copy link
Copy Markdown
Owner

What does this change?

This pull request introduces a standardized pre-commit code style and formatting setup across the repository, aligning it with OctoPrint core and plugin best practices. It adds configuration files for tools like pre-commit, isort, ruff, djlint, and prettier, and updates CI workflows to use these tools. The codebase and documentation have been updated to follow the new formatting and linting standards, and some minor code cleanups have been performed.

Pre-commit and Formatting Tooling:

  • Added .pre-commit-config.yaml to define a consistent set of pre-commit hooks (isort, ruff, djlint, prettier, codespell, shellcheck, etc.) for code formatting and quality checks.
  • Added configuration files for isort (.isort.cfg), ruff (ruff.toml), djlint (.djlintrc), and prettier (.prettierrc.yaml, .prettierignore) to enforce consistent code style across Python, Jinja, and frontend files. [1] [2] [3] [4] [5]

Continuous Integration (CI) Workflow Updates:

  • Updated .github/workflows/ci.yml to use pre-commit for linting instead of ruff directly, removed unnecessary Node.js/ShellCheck setup, and improved Codacy coverage upload with better environment variable handling and error tolerance. [1] [2] [3] [4] [5]

Documentation Improvements:

  • Updated CONTRIBUTING.md to instruct contributors to install and use pre-commit, and clarified that code style is now enforced by pre-commit hooks. [1] [2]

Python Codebase Formatting and Cleanup:

  • Reformatted Python files (octoprint_swapxyz/__init__.py, setup.py, tests) to comply with the new style (e.g., removal of legacy from __future__ imports, consistent trailing commas, function argument formatting, improved exception handling). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

Other Notable Changes:

  • Added pre-commit to requirements-dev.txt to ensure it's installed in development environments. (F4d4a689L1)
  • Minor formatting improvements to Jinja template files for readability and consistency. [1] [2]

These changes collectively ensure that code quality and formatting are automatically enforced, making contributions easier and more consistent across the project.

Closes #

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactoring / maintenance
  • CI

How was it tested?

Checklist

  • Existing settings keep working, or the change explains what users need to do
  • README updated, if the change affects it

- Introduced .djlintrc, .isort.cfg, .prettierignore, .prettierrc.yaml, and ruff.toml for code quality checks.
- Updated .editorconfig to align with new formatting standards.
- Modified CI workflow to utilize pre-commit for linting and formatting.
- Enhanced CONTRIBUTING.md to include pre-commit installation instructions.
- Updated requirements-dev.txt to include pre-commit as a dependency.
- Improved test cases for better readability and consistency.
@Ajimaru Ajimaru self-assigned this Dec 2, 2026
@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 78df3bfc-bcdd-48c6-a0ba-c5088675f065

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Ajimaru
Ajimaru merged commit d7ade9a into main Dec 2, 2026
21 checks passed
@Ajimaru
Ajimaru deleted the chore/pre-commit-hooks branch December 2, 2026 12:26
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