@@ -638,7 +638,46 @@ In addition to ``./ci/code_checks.sh``, some extra checks are run by
638
638
``pre-commit `` - see :ref: `here <contributing.pre-commit >` for how to
639
639
run them.
640
640
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 ``.
642
681
643
682
Optional dependencies
644
683
---------------------
@@ -712,7 +751,7 @@ Python (PEP8 / black)
712
751
pandas follows the `PEP8 <https://www.python.org/dev/peps/pep-0008/ >`_ standard
713
752
and uses `Black <https://black.readthedocs.io/en/stable/ >`_ and
714
753
`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 >`.
716
755
717
756
:ref: `Continuous Integration <contributing.ci >` will run those tools and
718
757
report any stylistic errors in your code. Therefore, it is helpful before
@@ -727,9 +766,6 @@ apply ``black`` as you edit files.
727
766
You should use a ``black `` version 20.8b1 as previous versions are not compatible
728
767
with the pandas codebase.
729
768
730
- If you wish to run these checks automatically, we encourage you to use
731
- :ref: `pre-commits <contributing.pre-commit >` instead.
732
-
733
769
One caveat about ``git diff upstream/master -u -- "*.py" | flake8 --diff ``: this
734
770
command will catch any stylistic errors in your changes specifically, but
735
771
be 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.
807
843
808
844
You can then verify the changes look ok, then git :ref: `commit <contributing.commit-code >` and :ref: `push <contributing.push-code >`.
809
845
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
-
849
846
Backwards compatibility
850
847
~~~~~~~~~~~~~~~~~~~~~~~
851
848
0 commit comments