Skip to content
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

Meta linting #88

Merged
merged 9 commits into from Feb 10, 2020
Merged

Meta linting #88

merged 9 commits into from Feb 10, 2020

Conversation

wadells
Copy link
Collaborator

@wadells wadells commented Feb 10, 2020

This PR introduces flake8 and black to the toolchain and ensures they are run against every pull request.

Fixes #83.

In fact, this will categorically prevent #83 from ever regressing.

Testing done:

I enabled Travis on my fork. All pushes to this branch can be seen here:

https://travis-ci.org/wadells/pandas-vet/builds?utm_medium=notification&utm_source=github_status

It is currently green.

Furthermore, I also nuked & rebuilt my venv to test setup instructions.

walt@wiwy:~/git/pandas-vet$ deactivate
walt@wiwy:~/git/pandas-vet$ rm -rf venv
walt@wiwy:~/git/pandas-vet$ virtualenv venv                                                                                                                                       walt@wiwy:~/git/pandas-vet$ source venv/bin/activate
walt@wiwy:~/git/pandas-vet$ pip install -r requirements_dev.txt 
Requirement already satisfied: pip==20.0.2 in ./venv/lib/python3.7/site-packages (from -r reqs/test.txt (line 2)) (20.0.2)
Requirement already satisfied: setuptools==45.2.0 in ./venv/lib/python3.7/site-packages (from -r reqs/test.txt (line 3)) (45.2.0)
Requirement already satisfied: wheel==0.34.2 in ./venv/lib/python3.7/site-packages (from -r reqs/test.txt (line 4)) (0.34.2)
Collecting pytest==5.3.5
  Using cached pytest-5.3.5-py3-none-any.whl (235 kB)
Collecting pytest-cov==2.8.1
  Using cached pytest_cov-2.8.1-py2.py3-none-any.whl (18 kB)
Collecting attrs==19.3.0
  Using cached attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting coverage==5.0.3
  Using cached coverage-5.0.3-cp37-cp37m-macosx_10_13_x86_64.whl (202 kB)
Collecting importlib-metadata==1.5.0
  Using cached importlib_metadata-1.5.0-py2.py3-none-any.whl (30 kB)
Collecting more-itertools==8.2.0
  Using cached more_itertools-8.2.0-py3-none-any.whl (43 kB)
Collecting packaging==20.1
  Using cached packaging-20.1-py2.py3-none-any.whl (36 kB)
Collecting pluggy==0.13.1
  Using cached pluggy-0.13.1-py2.py3-none-any.whl (18 kB)
Collecting py==1.8.1
  Using cached py-1.8.1-py2.py3-none-any.whl (83 kB)
Collecting pyparsing==2.4.6
  Using cached pyparsing-2.4.6-py2.py3-none-any.whl (67 kB)
Collecting six==1.14.0
  Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting wcwidth==0.1.8
  Using cached wcwidth-0.1.8-py2.py3-none-any.whl (17 kB)
Collecting zipp==1.1.0
  Downloading zipp-1.1.0-py2.py3-none-any.whl (4.6 kB)
Collecting flake8==3.7.9
  Using cached flake8-3.7.9-py2.py3-none-any.whl (69 kB)
Collecting entrypoints==0.3
  Using cached entrypoints-0.3-py2.py3-none-any.whl (11 kB)
Collecting mccabe==0.6.1
  Using cached mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pycodestyle==2.5.0
  Using cached pycodestyle-2.5.0-py2.py3-none-any.whl (51 kB)
Collecting pyflakes==2.1.1
  Using cached pyflakes-2.1.1-py2.py3-none-any.whl (59 kB)
Collecting black==19.10b0
  Using cached black-19.10b0-py36-none-any.whl (97 kB)
Collecting appdirs==1.4.3
  Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Collecting pathspec==0.7.0
  Using cached pathspec-0.7.0-py2.py3-none-any.whl (25 kB)
Collecting Click==7.0
  Using cached Click-7.0-py2.py3-none-any.whl (81 kB)
Processing /Users/walt/Library/Caches/pip/wheels/46/bc/80/2be94e7f74978bbc5d1a80646d53e76b0613c5507d862c2c0c/regex-2020.1.8-cp37-cp37m-macosx_10_13_x86_64.whl
Collecting typed-ast==1.4.1
  Using cached typed_ast-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl (223 kB)
Collecting toml==0.10.0
  Using cached toml-0.10.0-py2.py3-none-any.whl (25 kB)
Installing collected packages: wcwidth, zipp, importlib-metadata, attrs, pluggy, more-itertools, pyparsing, six, packaging, py, pytest, coverage, pytest-cov, mccabe, entrypoints, pyflakes, pycodestyle, flake8, Click, pathspec, regex, typed-ast, toml, appdirs, black
Successfully installed Click-7.0 appdirs-1.4.3 attrs-19.3.0 black-19.10b0 coverage-5.0.3 entrypoints-0.3 flake8-3.7.9 importlib-metadata-1.5.0 mccabe-0.6.1 more-itertools-8.2.0 packaging-20.1 pathspec-0.7.0 pluggy-0.13.1 py-1.8.1 pycodestyle-2.5.0 pyflakes-2.1.1 pyparsing-2.4.6 pytest-5.3.5 pytest-cov-2.8.1 regex-2020.1.8 six-1.14.0 toml-0.10.0 typed-ast-1.4.1 wcwidth-0.1.8 zipp-1.1.0
walt@wiwy:~/git/pandas-vet$ pip install -e .
Obtaining file:///Users/walt/git/pandas-vet
Requirement already satisfied: flake8>3.0.0 in ./venv/lib/python3.7/site-packages (from pandas-vet==0.2.2) (3.7.9)
Requirement already satisfied: attrs in ./venv/lib/python3.7/site-packages (from pandas-vet==0.2.2) (19.3.0)
Requirement already satisfied: pyflakes<2.2.0,>=2.1.0 in ./venv/lib/python3.7/site-packages (from flake8>3.0.0->pandas-vet==0.2.2) (2.1.1)
Requirement already satisfied: entrypoints<0.4.0,>=0.3.0 in ./venv/lib/python3.7/site-packages (from flake8>3.0.0->pandas-vet==0.2.2) (0.3)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./venv/lib/python3.7/site-packages (from flake8>3.0.0->pandas-vet==0.2.2) (0.6.1)
Requirement already satisfied: pycodestyle<2.6.0,>=2.5.0 in ./venv/lib/python3.7/site-packages (from flake8>3.0.0->pandas-vet==0.2.2) (2.5.0)
Installing collected packages: pandas-vet
  Running setup.py develop for pandas-vet
Successfully installed pandas-vet
walt@wiwy:~/git/pandas-vet$ flake8 pandas_vet setup.py tests --exclude tests/data
walt@wiwy:~/git/pandas-vet$ !black
walt@wiwy:~/git/pandas-vet$ black --verbose pandas_vet setup.py tests --exclude tests/data
pandas_vet/__pycache__/version.cpython-37.pyc ignored: matches the .gitignore file content
pandas_vet/__pycache__/__init__.cpython-37.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD001.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD012.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD004.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD901.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD013.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD005.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD015.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD003.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD010.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD006.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD009.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD011.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD007.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD002.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
tests/__pycache__/test_PD008.cpython-37-pytest-5.3.5.pyc ignored: matches the .gitignore file content
/Users/walt/git/pandas-vet/pandas_vet/version.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/setup.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD001.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD002.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD003.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD004.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD005.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD006.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD007.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD008.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD009.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD010.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD011.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD012.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD013.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD015.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/tests/test_PD901.py wasn't modified on disk since last run.
/Users/walt/git/pandas-vet/pandas_vet/__init__.py already well formatted, good job.
All done! ✨ 🍰 ✨
18 files left unchanged.
walt@wiwy:~/git/pandas-vet$ pytest tests    
============================================================ test session starts ============================================================
platform darwin -- Python 3.7.3, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/walt/git/pandas-vet
plugins: cov-2.8.1
collected 41 items                                                                                                                          

tests/test_PD001.py ...                                                                                                               [  7%]
tests/test_PD002.py ..                                                                                                                [ 12%]
tests/test_PD003.py ...                                                                                                               [ 19%]
tests/test_PD004.py ..                                                                                                                [ 24%]
tests/test_PD005.py ..                                                                                                                [ 29%]
tests/test_PD006.py ..                                                                                                                [ 34%]
tests/test_PD007.py ...                                                                                                               [ 41%]
tests/test_PD008.py ..                                                                                                                [ 46%]
tests/test_PD009.py ..                                                                                                                [ 51%]
tests/test_PD010.py ...                                                                                                               [ 58%]
tests/test_PD011.py ....                                                                                                              [ 68%]
tests/test_PD012.py ...                                                                                                               [ 75%]
tests/test_PD013.py ..                                                                                                                [ 80%]
tests/test_PD015.py ....                                                                                                              [ 90%]
tests/test_PD901.py ....                                                                                                              [100%]

============================================================ 41 passed in 0.20s =============================================================
walt@wiwy:~/git/pandas-vet$ 

As I look towards automated liniting in Travis, I want to make sure that
tests aren't going to break in unexpected fashions when the upstream
test tooling is updated unexpectedly. Thus we lock these version using
the output of `pip list --format freeze`.

This means that these version will need to be periodically updated to
capture the latest & greatest work, but those updates will happen in a
controlled fashion (a git commit).
Although we had readme instructions referencing this, the version to use
was not specified in requirements_test.txt. Lock it!

Also, max-line-length = 100 per @deppen8's preferred style.
@deppen8 uses black for formatting all the code in this repo.  Instead
of having flake8 fight with it, lets officially add black to the
toolchain.
The black version in the toolchain reflowed this file. In order to
prevent PR build failure we need to fix in in the repo.
@wadells wadells requested a review from deppen8 February 10, 2020 22:35
reqs/lint.txt Outdated
pycodestyle==2.5.0
pyflakes==2.1.1

# flake8, top level
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copypasta error: flake8 -> black

thomasjohns
thomasjohns previously approved these changes Feb 10, 2020
Copy link

@thomasjohns thomasjohns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) One thing we could add if desired is a README badge for black code style like https://github.com/psf/black#show-your-style.

deppen8
deppen8 previously approved these changes Feb 10, 2020
Copy link
Owner

@deppen8 deppen8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just accept these couple changes and good to go!

reqs/README.md Outdated Show resolved Hide resolved
reqs/README.md Outdated Show resolved Hide resolved
This will categorically prevent flake8 or black regressions from
entering the code base in the future.

Fixes deppen8#83.
Trying to install zipp==2.2.0 on 3.5 results in the following error:

  Could not find a version that satisfies the requirement zipp==2.2.0
  (from versions: 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.6.0, 1.0.0, 1.1.0)
@wadells wadells dismissed stale reviews from deppen8 and thomasjohns via 19e9b9d February 10, 2020 23:43
wadells and others added 2 commits February 10, 2020 15:47
Co-Authored-By: Jacob Deppen <deppen.8@gmail.com>
Co-Authored-By: Jacob Deppen <deppen.8@gmail.com>
@wadells wadells merged commit 6d20cf2 into deppen8:master Feb 10, 2020
@wadells wadells mentioned this pull request Feb 11, 2020
keturn added a commit to keturn/pandas-vet that referenced this pull request Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Existing flake8 errors in source and tests
3 participants