Enforce your chosen code style
What
Use tools to ensure that your code matches the style you wish to maintain
Why
Eases the process of developers writing code by ensuring that all developers use the same style
When
Early Development
Implementations:
- Format in CI
- Provides a repeatable environment to ensure formatting/style
- Has a lot of configuration options for different style preferences
- Independent of version control forge (ie GitHub, GitLab, etc.)
- May hold up contributions in Pull Requests due to maintainers needing to review style
- Formatting pre-commit hook
- Runs on the developer machine to ensure that commits are formatted correctly before being committed
- Ensures that only formatted commits get checked into version control
- Runs on every commit which can be detrimental to enabling contribution
- Higher learning curve for new developers
- Pep8speaks
- Provides a very succinct and clear description of style/linting changes needed on a PR
- Requires greater setup in GitHub to use
- Only works on GitHub
- Ruff
- Very fast and provides lots of linting options
- Highly configurable to match many different style options
- Provides a VSCode extension for developers
- Adopted by the NumPy project to help prevent breaking changes due to deprecations
- Black
- The standard in linting/formatting for Python projects
- Provides a GitHub Action for linting in CI