@@ -562,23 +562,38 @@ many errors as possible, but it may not correct *all* of them. Thus, it is
562
562
recommended that you run ``cpplint `` to double check and make any other style
563
563
fixes manually.
564
564
565
- Python (PEP8)
566
- ~~~~~~~~~~~~~
567
-
568
- *pandas * uses the `PEP8 <http://www.python.org/dev/peps/pep-0008/ >`_ standard.
569
- There are several tools to ensure you abide by this standard. Here are *some * of
570
- the more common ``PEP8 `` issues:
565
+ Python (PEP8 / black)
566
+ ~~~~~~~~~~~~~~~~~~~~~
571
567
572
- * we restrict line-length to 79 characters to promote readability
573
- * passing arguments should have spaces after commas, e.g. ``foo(arg1, arg2, kw1='bar') ``
568
+ *pandas * follows the `PEP8 <http://www.python.org/dev/peps/pep-0008/ >`_ standard
569
+ and uses `Black <https://black.readthedocs.io/en/stable/ >`_ and
570
+ `Flake8 <http://flake8.pycqa.org/en/latest/ >`_ to ensure a consistent code
571
+ format throughout the project.
574
572
575
- :ref: `Continuous Integration <contributing.ci >` will run
576
- the `flake8 <https://pypi.org/project/flake8 >`_ tool
577
- and report any stylistic errors in your code. Therefore, it is helpful before
578
- submitting code to run the check yourself on the diff::
573
+ :ref: `Continuous Integration <contributing.ci >` will run those tools and
574
+ report any stylistic errors in your code. Therefore, it is helpful before
575
+ submitting code to run the check yourself::
579
576
577
+ black pandas
580
578
git diff upstream/master -u -- "*.py" | flake8 --diff
581
579
580
+ to auto-format your code. Additionally, many editors have plugins that will
581
+ apply ``black `` as you edit files.
582
+
583
+ Optionally, you may wish to setup `pre-commit hooks <https://pre-commit.com/ >`_
584
+ to automatically run ``black `` and ``flake8 `` when you make a git commit. This
585
+ can be done by installing ``pre-commit ``::
586
+
587
+ pip install pre-commit
588
+
589
+ and then running::
590
+
591
+ pre-commit install
592
+
593
+ from the root of the pandas repository. Now ``black `` and ``flake8 `` will be run
594
+ each time you commit changes. You can skip these checks with
595
+ ``git commit --no-verify ``.
596
+
582
597
This command will catch any stylistic errors in your changes specifically, but
583
598
be beware it may not catch all of them. For example, if you delete the only
584
599
usage of an imported function, it is stylistically incorrect to import an
0 commit comments