diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000000..0b1c80159857 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +ci: + autofix_prs: false + autoupdate_schedule: 'quarterly' +exclude: | + (?x)^( + extern| + lib/matplotlib/mpl-data| + doc/devel/gitwash| + doc/users/prev| + doc/api/prev| + lib/matplotlib/tests/tinypages + ) +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: check-added-large-files + - id: check-docstring-first + - id: end-of-file-fixer + exclude_types: [svg] + - id: mixed-line-ending + - id: trailing-whitespace + exclude_types: [svg] + - repo: https://github.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + additional_dependencies: [pydocstyle>5.1.0, flake8-docstrings>1.4.0] + args: ["--docstring-convention=all"] diff --git a/doc/devel/development_setup.rst b/doc/devel/development_setup.rst index 468a7add7d75..c6aac3f1c467 100644 --- a/doc/devel/development_setup.rst +++ b/doc/devel/development_setup.rst @@ -60,6 +60,16 @@ true for ``*.py`` files. If you change the C-extension source (which might also happen if you change branches) you will have to re-run ``python -m pip install -ve .`` +Installing pre-commit hooks +=========================== +You can optionally install `pre-commit `_ hooks. +These will automatically check flake8 and other style issues when you run +``git commit``. The hooks are defined in the top level +``.pre-commit-config.yaml`` file. To install the hooks :: + + pip install pre-commit + pre-commit install + Installing additional dependencies for development ================================================== See :ref:`development-dependencies`. diff --git a/environment.yml b/environment.yml index d73d7a99f579..c75cf4a40733 100644 --- a/environment.yml +++ b/environment.yml @@ -48,6 +48,7 @@ dependencies: - nbformat!=5.0.0,!=5.0.1 - pandas!=0.25.0 - pikepdf + - pre-commit - pydocstyle>=5.1.0 - pytest!=4.6.0,!=5.4.0 - pytest-cov