To ensure consistent code style and formatting across the entire repository, we need to implement pre-commit hooks that automatically handle formatting and linting for multiple file types. This will improve code quality, catch errors early, and maintain clean code standards.
File Types to be Covered:
- Python files (
.py)
- Jupyter Notebooks (
.ipynb)
- YAML files (
.yml)
- Markdown files (
.md)
- Text files (
.txt)
Tasks:
- Add a
.pre-commit-config.yaml file in the root directory of the repository.
- Configure the following pre-commit hooks:
- Black: For automatic code formatting for Python and Jupyter Notebooks.
- Flake8: For linting Python files and Jupyter Notebooks.
- nbQA: To apply Black and Flake8 formatting and linting to Jupyter Notebooks (
.ipynb).
- Check YAML: To validate the format of YAML files.
- Markdownlint: To ensure style consistency in Markdown files.
- Trailing Whitespace, End-of-file fixer, and Check-merge-conflict: For cleaning up text files and ensuring proper file formatting.
- Install and activate the pre-commit hooks with the
pre-commit install command.
- Run
pre-commit run --all-files to apply the hooks to the entire codebase.
By implementing these hooks, we can maintain consistent formatting across all relevant file types and automatically prevent common formatting issues before code is committed.
To ensure consistent code style and formatting across the entire repository, we need to implement pre-commit hooks that automatically handle formatting and linting for multiple file types. This will improve code quality, catch errors early, and maintain clean code standards.
File Types to be Covered:
.py).ipynb).yml).md).txt)Tasks:
.pre-commit-config.yamlfile in the root directory of the repository..ipynb).pre-commit installcommand.pre-commit run --all-filesto apply the hooks to the entire codebase.By implementing these hooks, we can maintain consistent formatting across all relevant file types and automatically prevent common formatting issues before code is committed.