This pull request addresses closes #77 by adding pre-commit hooks to automatically handle code formatting and linting for various file types in the repository. These hooks help maintain consistent code style and formatting across Python files, Jupyter Notebooks, YAML, Markdown, and text files, ensuring better code quality and minimizing errors before committing.
Changes:
Added a .pre-commit-config.yaml file to configure the pre-commit hooks.
Configured the following hooks:
Black: Formats Python code and Jupyter notebooks.
nbQA: Applies Black and Flake8 to Jupyter Notebooks (.ipynb).
Check YAML: Validates YAML files.
Trailing Whitespace, End-of-file fixer, and Check-merge-conflict: Ensures clean formatting in text files.
Markdownlint: Enforces style consistency in Markdown files.
Key Updates:
Python Files: Black is used for automatic code formatting.
Jupyter Notebooks: Black and Flake8 linting are applied using nbQA.
YAML Files: Validation using the check-yaml hook.
Text Files: Whitespace and end-of-file formatting fixes are applied.
Markdown Files: Linting for style consistency using mdformat (replacing markdownlint).
Notes:
Removed the original markdownlint due to Ruby dependency issues and replaced it with a Python-based Markdown formatter (mdformat) to avoid Ruby-related setup complications.
Updated Python encoding to handle special characters in some files (e.g., files with emojis).
Modified linting rules for notebooks, and disabled nbqa-flake8 where necessary to avoid common linting errors (e.g., long lines, unused imports).
How to Test:
Install pre-commit by running:
pip install pre-commit
Run the following command to install the hooks:
pre-commit install
Apply the hooks to all files:
pre-commit run --all-files
This ensures that all files are formatted and linted according to the new configuration, improving code quality across the repository.
This pull request addresses closes #77 by adding pre-commit hooks to automatically handle code formatting and linting for various file types in the repository. These hooks help maintain consistent code style and formatting across Python files, Jupyter Notebooks, YAML, Markdown, and text files, ensuring better code quality and minimizing errors before committing.
Changes:
.pre-commit-config.yaml
file to configure the pre-commit hooks..ipynb
).Key Updates:
nbQA
.check-yaml
hook.mdformat
(replacing markdownlint).Notes:
markdownlint
due to Ruby dependency issues and replaced it with a Python-based Markdown formatter (mdformat
) to avoid Ruby-related setup complications.nbqa-flake8
where necessary to avoid common linting errors (e.g., long lines, unused imports).How to Test:
This ensures that all files are formatted and linted according to the new configuration, improving code quality across the repository.