Skip to content

PEP8: add in flake8 checking #11941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ after_script:
- if [ -f /tmp/doc.log ]; then cat /tmp/doc.log; fi
- source activate pandas && ci/print_versions.py
- ci/print_skipped.py /tmp/nosetests.xml
- ci/after_script.sh
- ci/lint.sh
26 changes: 0 additions & 26 deletions ci/after_script.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ci/install_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ conda info -a || exit 1

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

source activate pandas
Expand Down
17 changes: 17 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

echo "inside $0"

source activate pandas

echo flake8 pandas/core --statistics
flake8 pandas/core --statistics

RET="$?"

# we are disabling the return code for now
# to have Travis-CI pass. When the code
# passes linting, re-enable
#exit "$RET"

exit 0
1 change: 1 addition & 0 deletions ci/requirements_all.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
nose
flake8
sphinx
ipython
python-dateutil
Expand Down
1 change: 1 addition & 0 deletions ci/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pytz
numpy
cython
nose
flake8
51 changes: 31 additions & 20 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ If you are on Windows, then you will also need to install the compiler linkages:

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

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

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

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

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

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

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

::
Expand Down Expand Up @@ -396,7 +396,7 @@ And you'll have the satisfaction of seeing your new and improved documentation!
Building master branch documentation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Expand All @@ -410,30 +410,41 @@ Code standards
--------------

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

We've written a tool to check that your commits are PEP8 great, `pip install pep8radius
- we restrict line-length to 80 characters to promote readability
- passing arguments should have spaces after commas, e.g. ``foo(arg1, arg2, kw1='bar')``

The Travis-CI will run `flake8 <http://pypi.python.org/pypi/flake8>`_ tool and report
any stylistic errors in your code. Generating any warnings will cause the build to fail;
thus these are part of the requirements for submitting code to *pandas*.

It is helpful before submitting code to run this yourself on the diff::

git diff master | flake8 --diff

Furthermore, we've written a tool to check that your commits are PEP8 great, `pip install pep8radius
<https://github.com/hayd/pep8radius>`_. Look at PEP8 fixes in your branch vs master with::

pep8radius master --diff
pep8radius master --diff

and make these changes with::

pep8radius master --diff --in-place

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

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

Test-driven development/code writing
------------------------------------

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

This command is equivalent to::

asv run --quick --show-stderr --python=same
asv run --quick --show-stderr --python=same

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

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

Then you will need to push the branch (see below) forcefully to replace the current
Then you will need to push the branch (see below) forcefully to replace the current
commits with the new ones::

git push origin shiny-new-feature -f
Expand Down Expand Up @@ -714,8 +725,8 @@ Review your code
----------------

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

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

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

git push -f origin shiny-new-feature

This will automatically update your pull request with the latest code and restart the
This will automatically update your pull request with the latest code and restart the
Travis-CI tests.

Delete your merged branch (optional)
------------------------------------

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

git fetch upstream
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ versionfile_source = pandas/_version.py
versionfile_build = pandas/_version.py
tag_prefix = v
parentdir_prefix = pandas-

[flake8]
ignore = E226,F401