8000 STYLE: Fixing and refactoring linting by datapythonista · Pull Request #22863 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

STYLE: Fixing and refactoring linting #22863

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 19 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1811954
Refactoring lint.sh, wrong path pandas/src corrected, and made more c…
datapythonista Sep 27, 2018
6ace7ef
fixing linting errors in pxi.in files (linting was broken)
datapythonista Sep 28, 2018
a28a612
unifying the flake8 error codes that are being ignored
datapythonista Sep 28, 2018
af76f11
Restoring flake errors C406, C408 and C409
datapythonista Sep 28, 2018
07ebcd0
Unpinning flake8, to see if linting works with the latest version
datapythonista Sep 28, 2018
34e85f0
Synchronizing flake8 config in pep8speaks
datapythonista Sep 29, 2018
adcda47
Unifying all flake8 of .py files in one command, and moving excludes …
datapythonista Sep 29, 2018
c129197
Printing flake8 version, and moving doctests and check_import to lint.sh
datapythonista Sep 29, 2018
803b217
Moving linting from py2.7 to py3.6
datapythonista Sep 29, 2018
62a8813
Moving flake8/cpplint requirements to 3.6, as this is now where the l…
datapythonista Sep 29, 2018
720f18c
Merge remote-tracking branch 'upstream/master' into lint_refactor
datapythonista Sep 29, 2018
cabe353
lint.sh renamed to code_checks.sh, and parameters now supported to ca…
datapythonista Oct 1, 2018
9a76f58
Fixing linting script name in travis
datapythonista Oct 1, 2018
f4e17ad
Merging from master
datapythonista Oct 4, 2018
8000
56eca8f
merging from master
datapythonista Oct 9, 2018
879157f
Merge remote-tracking branch 'upstream/master' into lint_refactor
datapythonista Oct 9, 2018
0ec16fe
Adding documentation to the new linting script
datapythonista Oct 9, 2018
cd38de3
Fix linting error in the code, and added more information for when LI…
datapythonista Oct 9, 2018
8738e80
Fixing formatting in the documentation
datapythonista Oct 9, 2018
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
Prev Previous commit
Next Next commit
unifying the flake8 error codes that are being ignored
  • Loading branch information
datapythonista committed Sep 28, 2018
commit a28a612d6e62f6897127aef63d2655122a9a3313
36 changes: 14 additions & 22 deletions ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,35 @@ RET=0

### LINTING ###
Copy link
Contributor

Choose a reason for hiding this comment

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

so I would rather have these as 3 scripts, then a top-level script to call each one. That way we can call these individually (e.g. in the Makefile)

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean one script for linting (flake8+cpplint), one for the checks (grep) and one for the doctests, right? I think that makes sense, but considering we may want to move this to azure, I see different options:

  • Having 3 scripts as you say
  • Having one, but with a parameter (e.g. ./ci/lint.sh [lint|checks|doctests]). I think this makes things a bit simpler and more compact (as the 3 scripts will be very similar)
  • Leave it as it is, and move in a separate PR the content of this file to azure-pipelines.yml

You'll know better than me how often these checks are run locally or out of the CI, but as now flake8 is mainly flake8 . and the doctests will soon be flake 8 . --doctests I think it can make sense to just have them in azure. May be a script just for the grep checks if you think those are being run locally?


# We're ignoring the following codes across the board
# E402 module level import not at top of file
# E731 do not assign a lambda expression, use a def
# E741 do not use variables named 'l', 'O', or 'I'
# W503 line break before binary operator
# C406 Unnecessary (list/tuple) literal - rewrite as a dict literal.
# C408 Unnecessary (dict/list/tuple) call - rewrite as a literal.
# C409 Unnecessary (list/tuple) passed to tuple() - (remove the outer call to tuple()/rewrite as a tuple literal).
# C410 Unnecessary (list/tuple) passed to list() - (remove the outer call to list()/rewrite as a list literal).
# `setup.cfg` contains the list of error codes that are being ignored in flake8

# pandas/_libs/src is C code, so no need to search there.
MSG='Linting .py code' ; echo $MSG
flake8 pandas --filename=*.py --exclude pandas/_libs/src --ignore=C406,C408,C409,E402,E731,E741,W503
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pyx code' ; echo $MSG
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pxd and .pxi.in' ; echo $MSG
flake8 pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
flake8 pandas --filename=*.py --exclude pandas/_libs/src
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting setup.py' ; echo $MSG
flake8 setup.py --ignore=E402,E731,E741,W503
flake8 setup.py
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting scripts' ; echo $MSG
flake8 scripts --filename=*.py --ignore=C408,E402,E731,E741,W503
flake8 scripts --filename=*.py
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting asv benchmarks' ; echo $MSG
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/*.py --ignore=F811,C406,C408,C409,C410
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/*.py
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting doc scripts' ; echo $MSG
flake8 doc/make.py doc/source/conf.py --ignore=E402,E731,E741,W503
flake8 doc/make.py doc/source/conf.py
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pyx code' ; echo $MSG
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Linting .pxd and .pxi.in' ; echo $MSG
flake8 pandas/_libs --filename=*.pxi.in,*.pxd --select=E501,E302,E203,E111,E114,E221,E303,E231,E126,F403
RET=$(($RET + $?)) ; echo $MSG "DONE"

# readability/casting: Warnings about C casting instead of C++ casting
Expand Down
9 changes: 3 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ parentdir_prefix = pandas-

[flake8]
ignore =
W503, # line break before binary operator
E402, # module level import not at top of file
E722, # do not use bare except
E731, # do not assign a lambda expression, use a def
W503, # line break before binary operator
C405, # Unnecessary (list/tuple) literal - rewrite as a set literal.
C406, # Unnecessary (list/tuple) literal - rewrite as a dict literal.
C408, # Unnecessary (dict/list/tuple) call - rewrite as a literal.
C409, # Unnecessary (list/tuple) passed to tuple() - (remove the outer call to tuple()/rewrite as a tuple literal).
C410 # Unnecessary (list/tuple) passed to list() - (remove the outer call to list()/rewrite as a list literal).
E741 # ambiguous variable name 'l'
max-line-length = 79

[yapf]
Expand Down
0