Skip to content

Commit ad24759

Browse files
authored
DOC: Update flake8 command instructions (#16919)
1 parent 6858d0f commit ad24759

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
- [ ] closes #xxxx
22
- [ ] tests added / passed
3-
- [ ] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff`` (On Windows, ``git diff upstream/master -u -- "*.py" | flake8 --diff`` might work as an alternative.)
3+
- [ ] passes ``git diff upstream/master -u -- "*.py" | flake8 --diff``
44
- [ ] whatsnew entry

doc/source/contributing.rst

+17-7
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ the `flake8 <http://pypi.python.org/pypi/flake8>`_ tool
509509
and report any stylistic errors in your code. Therefore, it is helpful before
510510
submitting code to run the check yourself on the diff::
511511

512-
git diff master --name-only -- '*.py' | flake8 --diff
512+
git diff master -u -- "*.py" | flake8 --diff
513513

514514
This command will catch any stylistic errors in your changes specifically, but
515515
be beware it may not catch all of them. For example, if you delete the only
@@ -518,18 +518,28 @@ unused function. However, style-checking the diff will not catch this because
518518
the actual import is not part of the diff. Thus, for completeness, you should
519519
run this command, though it will take longer::
520520

521-
git diff master --name-only -- '*.py' | grep 'pandas/' | xargs -r flake8
521+
git diff master --name-only -- "*.py" | grep "pandas/" | xargs -r flake8
522522

523523
Note that on OSX, the ``-r`` flag is not available, so you have to omit it and
524524
run this slightly modified command::
525525

526-
git diff master --name-only -- '*.py' | grep 'pandas/' | xargs flake8
526+
git diff master --name-only -- "*.py" | grep "pandas/" | xargs flake8
527527

528-
Note that on Windows, ``grep``, ``xargs``, and other tools are likely
529-
unavailable. However, this has been shown to work on smaller commits in the
530-
standard Windows command line::
528+
Note that on Windows, these commands are unfortunately not possible because
529+
commands like ``grep`` and ``xargs`` are not available natively. To imitate the
530+
behavior with the commands above, you should run::
531531

532-
git diff master -u -- "*.py" | flake8 --diff
532+
git diff master --name-only -- "*.py"
533+
534+
This will list all of the Python files that have been modified. The only ones
535+
that matter during linting are any whose directory filepath begins with "pandas."
536+
For each filepath, copy and paste it after the ``flake8`` command as shown below:
537+
538+
flake8 <python-filepath>
539+
540+
Alternatively, you can install the ``grep`` and ``xargs`` commands via the
541+
`MinGW <http://www.mingw.org/>`__ toolchain, and it will allow you to run the
542+
commands above.
533543

534544
Backwards Compatibility
535545
~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)