pre-commit scripts

pre-commit-hooks

The pre-commit framework already comes with a whole range of scripts, including:

check-added-large-files

prevents large files from being transferred

check-case-conflict

looks for files that would conflict in case-insensitive file systems

check-executables-have-shebangs

makes sure that (non-binary) executables have a shebang line

check-shebang-scripts-are-executable

makes sure (non-binary) files are executable with a shebang line

check-merge-conflict

searches for files containing merge-conflict strings

check-symlinks

checks for symlinks that don’t point to anything

destroyed-symlinks

detects symlinks that have been changed into regular files with the contents of the path the symlink points to.

no-commit-to-branch

protects branches before committing

pygrep-hooks

provides regular expressions for Python and reStructuredText, including:

python-no-log-warn

search for the deprecated .warn() method of Python loggers

python-use-type-annotations

forces type-annotations to be used instead of type-comments

rst-backticks

detects the use of single backticks when writing reStructuredText

rst-directive-colons

detects that reStructuredText directives do not end with a colon or a space before the colon

rst-inline-touching-normal

detects that inline code is used in normal text in reStructuredText

text-unicode-replacement-char

prevents files that contain UTF-8 Unicode Replacement Characters

Linters and formatters

They are provided in separate repositories, including:

autopep8

provides autopep8 for the pre-commit framework

mypy

provides mypy

validate-pyproject

checks pyproject.toml files

sp-repo-review

evaluates existing repos against the Scientific Python guidelines.

clang-format

provides clang-format-wheel

csslint

provides csslint

scss-lint

provides scss-lint

eslint

provides eslint

fixmyjs

provides fixmyjs

prettier

provides prettier

black

for formatting Python code

black

Python code formatter

black-jupyter

Python code formatter for Jupyter notebooks

Python Code Quality Authority

Code quality tools (and plugins) for the Python programming language:

flake8

promotes the enforcement of a consistent Python style

autoflake

removes unused imports and unused variables from Python code

bandit

tool for finding security vulnerabilities in Python code

pydocstyle

static analysis tool to check compliance with Python docstring conventions

docformatter

formats docstrings according to PEP 257

pylint

Python linter

doc8

executes doc8 for linting documents

prospector

analyses Python code with prospector

isort

sorts Python imports

nbQA

runs isort, pyupgrade, mypy, pylint, flake8 and more on Jupyter notebooks:

nbqa

runs any standard Python code quality tool on a Jupyter notebook

nbqa-black

runs black on a Jupyter notebook

nbqa-check-ast

runs check-ast on a Jupyter notebook

nbqa-flake8

runs flake8 on a Jupyter notebook

nbqa-isort

runs isort on a Jupyter notebook

nbqa-mypy

runs mypy on a Jupyter notebook

nbqa-pylint

runs pylint on a Jupyter notebook

nbqa-pyupgrade

runs ppyupgrade on a Jupyter notebook

nbqa-yapf

runs yapf on a Jupyter notebook

nbqa-autopep8

runs autopep8 on a Jupyter notebook

nbqa-pydocstyle

runs pydocstyle on a Jupyter notebook

nbqa-ruff

runs ruff on a Jupyter notebook

blacken-docs

applies black to Python code blocks in documentation files

Miscellaneous

pyupgrade

automatically updates the syntax for newer versions

reorder-python-imports

reorders imports into Python files

dead

detects dead Python code

python-safety-dependencies-check

analyses Python requirements for known security vulnerabilities

gitlint

Git commit message linter

nbstripout

removes the output of Jupyter Notebooks

ripsecrets

prevents secret keys from being included in your source code

detect-secrets

detects high entropy strings that are likely to be passwords

pip-compile

automatically compiles requirements

kontrolilo

Tool to control licences for OSS dependencies

See also