@@ -638,7 +638,46 @@ In addition to ``./ci/code_checks.sh``, some extra checks are run by
638638``pre-commit `` - see :ref: `here <contributing.pre-commit >` for how to
639639run them.
640640
641- Additional standards are outlined on the :ref: `pandas code style guide <code_style >`
641+ Additional standards are outlined on the :ref: `pandas code style guide <code_style >`.
642+
643+ .. _contributing.pre-commit :
644+
645+ Pre-commit
646+ ~~~~~~~~~~
647+
648+ You can run many of these styling checks manually as we have described above. However,
649+ we encourage you to use `pre-commit hooks <https://pre-commit.com/ >`_ instead
650+ to automatically run ``black ``, ``flake8 ``, ``isort `` when you make a git commit. This
651+ can be done by installing ``pre-commit ``::
652+
653+ pip install pre-commit
654+
655+ and then running::
656+
657+ pre-commit install
658+
659+ from the root of the pandas repository. Now all of the styling checks will be
660+ run each time you commit changes without your needing to run each one manually.
661+ In addition, using this pre-commit hook will also allow you to more easily
662+ remain up-to-date with our code checks as they change.
663+
664+ Note that if needed, you can skip these checks with ``git commit --no-verify ``.
665+
666+ If you don't want to use ``pre-commit `` as part of your workflow, you can still use it
667+ to run its checks by running::
668+
669+ pre-commit run --files <files you have modified>
670+
671+ without having to have done ``pre-commit install `` beforehand.
672+
673+ .. note ::
674+
675+ If you have conflicting installations of ``virtualenv ``, then you may get an
676+ error - see `here <https://github.com/pypa/virtualenv/issues/1875 >`_.
677+
678+ Also, due to a `bug in virtualenv <https://github.com/pypa/virtualenv/issues/1986 >`_,
679+ you may run into issues if you're using conda. To solve this, you can downgrade
680+ ``virtualenv `` to version ``20.0.33 ``.
642681
643682Optional dependencies
644683---------------------
@@ -712,7 +751,7 @@ Python (PEP8 / black)
712751pandas follows the `PEP8 <https://www.python.org/dev/peps/pep-0008/ >`_ standard
713752and uses `Black <https://black.readthedocs.io/en/stable/ >`_ and
714753`Flake8 <http://flake8.pycqa.org/en/latest/ >`_ to ensure a consistent code
715- format throughout the project.
754+ format throughout the project. We encourage you to use :ref: ` pre-commits < contributing.pre-commit >`.
716755
717756:ref: `Continuous Integration <contributing.ci >` will run those tools and
718757report any stylistic errors in your code. Therefore, it is helpful before
@@ -727,9 +766,6 @@ apply ``black`` as you edit files.
727766You should use a ``black `` version 20.8b1 as previous versions are not compatible
728767with the pandas codebase.
729768
730- If you wish to run these checks automatically, we encourage you to use
731- :ref: `pre-commits <contributing.pre-commit >` instead.
732-
733769One caveat about ``git diff upstream/master -u -- "*.py" | flake8 --diff ``: this
734770command will catch any stylistic errors in your changes specifically, but
735771be beware it may not catch all of them. For example, if you delete the only
@@ -807,45 +843,6 @@ Where similar caveats apply if you are on OSX or Windows.
807843
808844You can then verify the changes look ok, then git :ref: `commit <contributing.commit-code >` and :ref: `push <contributing.push-code >`.
809845
810- .. _contributing.pre-commit :
811-
812- Pre-commit
813- ~~~~~~~~~~
814-
815- You can run many of these styling checks manually as we have described above. However,
816- we encourage you to use `pre-commit hooks <https://pre-commit.com/ >`_ instead
817- to automatically run ``black ``, ``flake8 ``, ``isort `` when you make a git commit. This
818- can be done by installing ``pre-commit ``::
819-
820- pip install pre-commit
821-
822- and then running::
823-
824- pre-commit install
825-
826- from the root of the pandas repository. Now all of the styling checks will be
827- run each time you commit changes without your needing to run each one manually.
828- In addition, using this pre-commit hook will also allow you to more easily
829- remain up-to-date with our code checks as they change.
830-
831- Note that if needed, you can skip these checks with ``git commit --no-verify ``.
832-
833- If you don't want to use ``pre-commit `` as part of your workflow, you can still use it
834- to run its checks by running::
835-
836- pre-commit run --files <files you have modified>
837-
838- without having to have done ``pre-commit install `` beforehand.
839-
840- .. note ::
841-
842- If you have conflicting installations of ``virtualenv ``, then you may get an
843- error - see `here <https://github.com/pypa/virtualenv/issues/1875 >`_.
844-
845- Also, due to a `bug in virtualenv <https://github.com/pypa/virtualenv/issues/1986 >`_,
846- you may run into issues if you're using conda. To solve this, you can downgrade
847- ``virtualenv `` to version ``20.0.33 ``.
848-
849846Backwards compatibility
850847~~~~~~~~~~~~~~~~~~~~~~~
851848
0 commit comments