Add pre-commit hooks for Python & Scala, configure Black/Ruff/Flake8/scalafmt, and reformat code #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add pre-commit hooks for Python & Scala, configure Black/Ruff/Flake8/scalafmt, and reformat code
Overview
This PR introduces a consistent style/linting workflow for both Python and Scala modules in this project. It adds a new
.pre-commit-config.yamlplus supporting configuration files so that any staged changes will be automatically formatted and checked before commit.Key Highlights
.pre-commit-config.yaml
isolation-forest-onnx/isolation-forest/Python
pyproject.tomlinisolation-forest-onnx/for Black (88-char line length,py39target).setup.cfgfor Flake8 to match line length = 88 and ignore certain dirs.Scala
scalafmt.confinisolation-forest/(maxColumn=100, trailing commas, docstring style, etc.).General Cleanup
How to Use
Install/Update pre-commit locally:
Install scalafmt (for Scala formatting), for example:
Re-install hooks (at the repository root):
Verify by committing any changes to
.pyor.scalafiles. The configured hooks will run automatically, formatting code and checking for lint errors.Testing
pre-commit run --all-filesto confirm hooks apply cleanly on the entire codebase.pytest) and Scala (e.g.,sbt testor Gradle equivalent).