Skip to content

Added pre-commit-config.yaml #27273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions doc/source/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down Expand Up @@ -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 <contributing.commit-code>` and :ref:`push <contributing.push-code>`.

.. _contributing.pre_commit:

Pre-Commit Hooks
~~~~~~~~~~~~~~~~

Install the `pre commit <https://github.com/pre-commit/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
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down