Package: pyproject-pre-commit
pyproject-pre-commitpre-commit hooks for python projects using pyproject.toml..pre-commit-hooks.yamlprovides pre-defined ids which you just need to add these ids to your.pre-commit-config.yaml.RequirementPython 3.11, 3.10, 3.9, 3.8Poetry (For development)InstallationIf your project uses poetry, do:$ poetry add --group dev pyproject-pre-commitOtherwise, install by pip:$ pip install pyproject-pre-commitThe repository featuresIf you install this package, several linters/formatters will be installed, too.This repository has following hooks forpre-commit:For Pythonblack-diff: Just show Black result.black: Black: The uncompromising Python code formatter.blacken-docs: Runblackon python code blocks in documentation files.autoflake-diff: Just show autoflake result.autoflake: autoflake removes unused imports and unused variables from Python code.autopep8-diff: Just show autopep8.autopep8: autopep8 automatically formats Python code to conform to the PEP 8 style guide.isort-diff: Just show isort result.isort: isort your imports, so you don't have to.flake8:flake8is a command-line utility for enforcing style consistency across Python projects.With following plugins:flake8-pyprojectflake8-annotations-complexityflake8-bugbearflake8-builtinsflake8-comprehensionsflake8-debuggerflake8-docstringsflake8-executableflake8-pep3101flake8-printflake8-rst-docstringsflake8-string-formatpep8-namingpycodestylebandit: Bandit is a tool for finding common security issues in Python code.mypy: Mypy is a static type checker for Python.For Shell scriptshellcheck: ShellCheck - A shell script static analysis toolFor Markdownmdformat-check: Just show mdformat result.mdformat: CommonMark compliant Markdown formatter.with following plugins:mdformat-gfmmdformat-frontmattermdformat-footnoteAll tools are installed as dependencies of this package.shellcheck and mdformat are given in addition to python tools
as they can be managed by pip and most projects have README.md
and some have shell scripts.For tools which can format files, there are additional ids ids with-diffor--checkwhich just show the results and not modify files.
You can see the difference after formatting if you place these ids before ids w/o--diffor--check.You can set options in pyproject.toml for all tools above:flake8: flake8-pyproject allows to read options from pyproject.tomlbandit: There is a plugin for the flake8, but plugin version does not read options from pyproject.toml even with pyproject.toml. Therefore, use bandit directly and give-c pyproject.tomloption in the hooks..pre-commit-config.yamlPrepare.pre-commit-config.yamllike:repos:-repo:https://github.com/rcmdnk/pyproject-pre-commitrev:v0.1.1hooks:-id:black-diff-id:black-id:blacken-docs-id:autoflake-diff-id:autoflake-id:autopep8-diff-id:autopep8-id:isort-diff-id:isort-id:flake8-id:bandit-id:mypy-id:shellcheck-id:mdformat-check-id:mdformatThis can be made byppccommand:$ ppc --pre-commit > .pre-commit-config.yamlIf you already have it, add hooks w/orepos:by$ ppc --pre-commit |grep -v "^repos:" >> .pre-commit-config.yamlYou may want to modify after adding these configurations.pyproject.tomlYou can set options in pyproject.toml for all tools.Example options can be made byppccommand:$ ppc --pyproject >> pyproject.tomlYou may want to modify after adding these configurations.