From 51890258e1201c679c0c064153710611cb15ff1c Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Sun, 7 Jul 2019 07:17:15 -0500 Subject: [PATCH] Added pre-commit-config.yaml --- .pre-commit-config.yaml | 16 ++++++++++++++++ doc/source/development/contributing.rst | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000..9c8d04ea91a88 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.7 + hooks: + - id: flake8 + language: python_venv + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.20 + hooks: + - id: isort + language: python_venv + - repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black + language_version: python3.7 diff --git a/doc/source/development/contributing.rst b/doc/source/development/contributing.rst index dde1db7e693de..d39df2a80b402 100644 --- a/doc/source/development/contributing.rst +++ b/doc/source/development/contributing.rst @@ -490,6 +490,9 @@ being rendered properly) and it also validates the doctests. It is possible to run the checks independently by using the parameters ``lint``, ``patterns`` and ``doctests`` (e.g. ``./ci/code_checks.sh lint``). +We recommend using :ref:`contributing.pre_commit`. These will run a few fast +checks each time you make a commit. + In addition, because a lot of people use our library, it is important that we do not make sudden changes to the code that could have the potential to break a lot of user code as a result, that is, we need it to be as *backwards compatible* @@ -650,6 +653,19 @@ The `--recursive` flag can be passed to sort all files in a directory. You can then verify the changes look ok, then git :ref:`commit ` and :ref:`push `. +.. _contributing.pre_commit: + +Pre-Commit Hooks +~~~~~~~~~~~~~~~~ + +Install the `pre commit `_ tool. Then, from the +root of the ``pandas`` repository, run ``pre-commit install`` to install a few plugins +like black, isort, and flake8. These tools will automatically be run on each commit. If the +tool reformats automatically (black, isort) then you can preview the changes before before +staging and committing with ``git diff``. + +You can skip the checks with ``git commit --no-verify``. + Backwards compatibility ~~~~~~~~~~~~~~~~~~~~~~~