Skip to content

Commit ab1eb2a

Browse files
committed
Merge pull request #11941 from jreback/flake8
PEP8: add in flake8 checking
2 parents a1e7d53 + 9bea2ee commit ab1eb2a

8 files changed

+55
-48
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ after_script:
173173
- if [ -f /tmp/doc.log ]; then cat /tmp/doc.log; fi
174174
- source activate pandas && ci/print_versions.py
175175
- ci/print_skipped.py /tmp/nosetests.xml
176-
- ci/after_script.sh
176+
- ci/lint.sh

ci/after_script.sh

-26
This file was deleted.

ci/install_conda.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ conda info -a || exit 1
8080

8181
# build deps
8282
REQ="ci/requirements-${TRAVIS_PYTHON_VERSION}${JOB_TAG}.build"
83-
time conda create -n pandas python=$TRAVIS_PYTHON_VERSION nose || exit 1
83+
time conda create -n pandas python=$TRAVIS_PYTHON_VERSION nose flake8 || exit 1
8484
time conda install -n pandas --file=${REQ} || exit 1
8585

8686
source activate pandas

ci/lint.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
echo "inside $0"
4+
5+
source activate pandas
6+
7+
echo flake8 pandas/core --statistics
8+
flake8 pandas/core --statistics
9+
10+
RET="$?"
11+
12+
# we are disabling the return code for now
13+
# to have Travis-CI pass. When the code
14+
# passes linting, re-enable
15+
#exit "$RET"
16+
17+
exit 0

ci/requirements_all.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
nose
2+
flake8
23
sphinx
34
ipython
45
python-dateutil

ci/requirements_dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pytz
33
numpy
44
cython
55
nose
6+
flake8

doc/source/contributing.rst

+31-20
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ If you are on Windows, then you will also need to install the compiler linkages:
176176

177177
This will create the new environment, and not touch any of your existing environments,
178178
nor any existing python installation. It will install all of the basic dependencies of
179-
*pandas*, as well as the development and testing tools. If you would like to install
179+
*pandas*, as well as the development and testing tools. If you would like to install
180180
other dependencies, you can install them as follows::
181181

182182
conda install -n pandas_dev -c pandas pytables scipy
@@ -294,7 +294,7 @@ Some other important things to know about the docs:
294294
In [2]: x**3
295295
Out[2]: 8
296296

297-
Almost all code examples in the docs are run (and the output saved) during the
297+
Almost all code examples in the docs are run (and the output saved) during the
298298
doc build. This approach means that code examples will always be up to date,
299299
but it does make the doc building a bit more complex.
300300

@@ -337,7 +337,7 @@ Furthermore, it is recommended to have all `optional dependencies
337337
<http://pandas.pydata.org/pandas-docs/dev/install.html#optional-dependencies>`_
338338
installed. This is not strictly necessary, but be aware that you will see some error
339339
messages when building the docs. This happens because all the code in the documentation
340-
is executed during the doc build, and so code examples using optional dependencies
340+
is executed during the doc build, and so code examples using optional dependencies
341341
will generate errors. Run ``pd.show_versions()`` to get an overview of the installed
342342
version of all dependencies.
343343

@@ -357,7 +357,7 @@ So how do you build the docs? Navigate to your local
357357
Then you can find the HTML output in the folder ``pandas/doc/build/html/``.
358358

359359
The first time you build the docs, it will take quite a while because it has to run
360-
all the code examples and build all the generated docstring pages. In subsequent
360+
all the code examples and build all the generated docstring pages. In subsequent
361361
evocations, sphinx will try to only build the pages that have been modified.
362362

363363
If you want to do a full clean build, do::
@@ -368,7 +368,7 @@ If you want to do a full clean build, do::
368368
Starting with *pandas* 0.13.1 you can tell ``make.py`` to compile only a single section
369369
of the docs, greatly reducing the turn-around time for checking your changes.
370370
You will be prompted to delete ``.rst`` files that aren't required. This is okay because
371-
the prior versions of these files can be checked out from git. However, you must make sure
371+
the prior versions of these files can be checked out from git. However, you must make sure
372372
not to commit the file deletions to your Git repository!
373373

374374
::
@@ -396,7 +396,7 @@ And you'll have the satisfaction of seeing your new and improved documentation!
396396
Building master branch documentation
397397
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398398

399-
When pull requests are merged into the *pandas* ``master`` branch, the main parts of
399+
When pull requests are merged into the *pandas* ``master`` branch, the main parts of
400400
the documentation are also built by Travis-CI. These docs are then hosted `here
401401
<http://pandas-docs.github.io/pandas-docs-travis>`__.
402402

@@ -410,30 +410,41 @@ Code standards
410410
--------------
411411

412412
*pandas* uses the `PEP8 <http://www.python.org/dev/peps/pep-0008/>`_ standard.
413-
There are several tools to ensure you abide by this standard.
413+
There are several tools to ensure you abide by this standard. Here are *some* of
414+
the more common ``PEP8`` issues:
414415

415-
We've written a tool to check that your commits are PEP8 great, `pip install pep8radius
416+
- we restrict line-length to 80 characters to promote readability
417+
- passing arguments should have spaces after commas, e.g. ``foo(arg1, arg2, kw1='bar')``
418+
419+
The Travis-CI will run `flake8 <http://pypi.python.org/pypi/flake8>`_ tool and report
420+
any stylistic errors in your code. Generating any warnings will cause the build to fail;
421+
thus these are part of the requirements for submitting code to *pandas*.
422+
423+
It is helpful before submitting code to run this yourself on the diff::
424+
425+
git diff master | flake8 --diff
426+
427+
Furthermore, we've written a tool to check that your commits are PEP8 great, `pip install pep8radius
416428
<https://github.com/hayd/pep8radius>`_. Look at PEP8 fixes in your branch vs master with::
417429

418-
pep8radius master --diff
430+
pep8radius master --diff
419431

420432
and make these changes with::
421433

422434
pep8radius master --diff --in-place
423435

424-
Alternatively, use the `flake8 <http://pypi.python.org/pypi/flake8>`_ tool for checking
425-
the style of your code. Additional standards are outlined on the `code style wiki
436+
Additional standards are outlined on the `code style wiki
426437
page <https://github.com/pydata/pandas/wiki/Code-Style-and-Conventions>`_.
427438

428-
Please try to maintain backward compatibility. *pandas* has lots of users with lots of
439+
Please try to maintain backward compatibility. *pandas* has lots of users with lots of
429440
existing code, so don't break it if at all possible. If you think breakage is required,
430441
clearly state why as part of the pull request. Also, be careful when changing method
431442
signatures and add deprecation warnings where needed.
432443

433444
Test-driven development/code writing
434445
------------------------------------
435446

436-
*pandas* is serious about testing and strongly encourages contributors to embrace
447+
*pandas* is serious about testing and strongly encourages contributors to embrace
437448
`test-driven development (TDD) <http://en.wikipedia.org/wiki/Test-driven_development>`_.
438449
This development process "relies on the repetition of a very short development cycle:
439450
first the developer writes an (initially failing) automated test case that defines a desired
@@ -556,7 +567,7 @@ It can also be useful to run tests in your current environment. You can simply d
556567

557568
This command is equivalent to::
558569

559-
asv run --quick --show-stderr --python=same
570+
asv run --quick --show-stderr --python=same
560571

561572
This will launch every test only once, display stderr from the benchmarks, and use your local ``python`` that comes from your ``$PATH``.
562573

@@ -680,7 +691,7 @@ To squash to the master branch do::
680691
Use the ``s`` option on a commit to ``squash``, meaning to keep the commit messages,
681692
or ``f`` to ``fixup``, meaning to merge the commit messages.
682693

683-
Then you will need to push the branch (see below) forcefully to replace the current
694+
Then you will need to push the branch (see below) forcefully to replace the current
684695
commits with the new ones::
685696

686697
git push origin shiny-new-feature -f
@@ -714,8 +725,8 @@ Review your code
714725
----------------
715726

716727
When you're ready to ask for a code review, file a pull request. Before you do, once
717-
again make sure that you have followed all the guidelines outlined in this document
718-
regarding code style, tests, performance tests, and documentation. You should also
728+
again make sure that you have followed all the guidelines outlined in this document
729+
regarding code style, tests, performance tests, and documentation. You should also
719730
double check your branch changes against the branch it was based on:
720731

721732
#. Navigate to your repository on GitHub -- https://github.com/your-user-name/pandas
@@ -735,7 +746,7 @@ release. To submit a pull request:
735746

736747
#. Navigate to your repository on GitHub
737748
#. Click on the ``Pull Request`` button
738-
#. You can then click on ``Commits`` and ``Files Changed`` to make sure everything looks
749+
#. You can then click on ``Commits`` and ``Files Changed`` to make sure everything looks
739750
okay one last time
740751
#. Write a description of your changes in the ``Preview Discussion`` tab
741752
#. Click ``Send Pull Request``.
@@ -747,14 +758,14 @@ updated. Pushing them to GitHub again is done by::
747758

748759
git push -f origin shiny-new-feature
749760

750-
This will automatically update your pull request with the latest code and restart the
761+
This will automatically update your pull request with the latest code and restart the
751762
Travis-CI tests.
752763

753764
Delete your merged branch (optional)
754765
------------------------------------
755766

756767
Once your feature branch is accepted into upstream, you'll probably want to get rid of
757-
the branch. First, merge upstream master into your branch so git knows it is safe to
768+
the branch. First, merge upstream master into your branch so git knows it is safe to
758769
delete your branch::
759770

760771
git fetch upstream

setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ versionfile_source = pandas/_version.py
1010
versionfile_build = pandas/_version.py
1111
tag_prefix = v
1212
parentdir_prefix = pandas-
13+
14+
[flake8]
15+
ignore = E226,F401

0 commit comments

Comments
 (0)