Build your own Python package (3)
Here is the content for the series of Build your own Python package:
- Make your package installable
- Generate doc for your package
- Format your codes
- Add testing for your codes
Format your codes
references:
- https://pre-commit.com
- https://pre-commit.com/hooks.html
- https://dev.to/angu10/setting-up-pre-commit-hooks-in-github-ensuring-code-quality-and-consistency-289n
TBC intro
pip install pre-commit
pre-commit init
# prepraing the configuration file .pre-commit-config.yaml
pre-commit run --all-files
Here is an example of .pre-commit-config.yaml
:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-added-large-files
args: ["--maxkb=1024", "--enforce-all"]
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
# Python
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
files: \.py$
Enjoy Reading This Article?
Here are some more articles you might like to read next: