From b713c401813d56fad53bd3e2134953490e4bcf31 Mon Sep 17 00:00:00 2001 From: askpatricw <4002194+askpatrickw@users.noreply.github.com> Date: Wed, 6 Jan 2021 00:21:44 -0800 Subject: [PATCH 1/2] Change Make to run pylint and black --- Makefile | 17 ++++++++--------- make/make.py | 39 ++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index b0015e1..f6c5c7f 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ GREP_T_FLAG := $(shell test $$(uname) = Linux && echo -T) all: @echo "\nThere is no default Makefile target right now. Try:\n" @echo "make clean - reset the project and remove auto-generated assets." - @echo "make pyflakes - run the PyFlakes code checker." - @echo "make pycodestyle - run the PEP8 style checker." + @ecxho "make black - runs Black Python code formatter." + @echo "make pylint - runs Python Linter." @echo "make test - run the test suite." @echo "make coverage - view a report on test coverage." @echo "make tidy - tidy code with the 'black' formatter." @@ -28,13 +28,12 @@ clean: find . \( -name '*.tgz' -o -name dropin.cache \) -delete find . | grep -E "(__pycache__)" | xargs rm -rf -pyflakes: - # search the current directory tree for .py files, skipping docs and _build, var directories, feeding them to pyflakes - find . \( -name _build -o -name var -o -path ./docs -o -name .env \) -type d -prune -o -name '*.py' -print0 | $(XARGS) pyflakes -pycodestyle: - # search the current directory tree for .py files, skipping _build and var directories, feeding them to pycodestyle - find . \( -name _build -o -name var -o -name .env \) -type d -prune -o -name '*.py' -print0 | $(XARGS) -n 1 pycodestyle --repeat --exclude=docs/*,.vscode/* --ignore=E731,E402,W504,W503 +black: + black --check --target-version=py35 . + +pylint: + pylint circup.py test: clean pytest --random-order @@ -46,7 +45,7 @@ tidy: clean @echo "\nTidying code with black..." black --target-version=py35 . -check: clean tidy pycodestyle pyflakes coverage +check: clean tidy black pylint coverage dist: check @echo "\nChecks pass, good to package..." diff --git a/make/make.py b/make/make.py index aa7785d..5dab996 100644 --- a/make/make.py +++ b/make/make.py @@ -9,9 +9,8 @@ import shutil import subprocess PYTEST = "pytest" -PYFLAKES = "pyflakes" -PYCODESTYLE = "pycodestyle" BLACK = "black" +PYLINT = "pylint" INCLUDE_PATTERNS = {"*.py"} EXCLUDE_PATTERNS = {"build/*", "docs/*"} @@ -132,33 +131,27 @@ def coverage(): @export -def pyflakes(*pyflakes_args): +def black(*black_args): """ - Run the PyFlakes code checker. - - Call pyflakes on all .py files outside the docs and contrib directories. + Run Black in check mode """ - print("\npyflakes") - os.environ["PYFLAKES_BUILTINS"] = "_" - return _process_code(PYFLAKES, False, *pyflakes_args) + args = (BLACK, "--check", "--target-version", "py35", ".") + black_args + result = subprocess.run(args).returncode + if result > 0: + return result @export -def pycodestyle(*pycodestyle_args): +def pylint(): """ - Run the PEP8 style checker. + Run python Linter """ - print("\nPEP8") - args = ("--ignore=E731,E402,W504,W503",) + pycodestyle_args - return _process_code(PYCODESTYLE, False, *args) - - -@export -def pep8(*pep8_args): - """ - Run the PEP8 style checker. - """ - return pycodestyle(*pep8_args) + # args = ("circup.py",) + # return _process_code(PYLINT, False, *args) + args = (PYLINT, "circup.py") + result = subprocess.run(args).returncode + if result > 0: + return result @export @@ -179,7 +172,7 @@ def check(): Run all the checkers and tests. """ print("\nCheck") - funcs = [clean, tidy, pyflakes, pycodestyle, coverage] + funcs = [clean, tidy, black, pylint, coverage] for func in funcs: return_code = func() if return_code != 0: From a4ee697062ae3a4a72e9650d49437f970c786782 Mon Sep 17 00:00:00 2001 From: askpatricw <4002194+askpatrickw@users.noreply.github.com> Date: Wed, 6 Jan 2021 00:28:59 -0800 Subject: [PATCH 2/2] remove dependencies add pylint --- requirements.txt | 3 +-- setup.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index a914b7c..e02cdf0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,9 +20,8 @@ packaging==19.1 pkginfo==1.5.0.1 pluggy==0.12.0 py==1.8.0 -pycodestyle==2.5.0 -pyflakes==2.1.1 Pygments==2.4.2 +pylint pyparsing==2.4.2 pytest==5.1.2 pytest-cov==2.7.1 diff --git a/setup.py b/setup.py index 97ba9cd..8d0bfe4 100644 --- a/setup.py +++ b/setup.py @@ -27,12 +27,11 @@ install_requires = [ extras_require = { "tests": [ "pytest", + "pylint", "pytest-cov", "pytest-random-order>=1.0.0", "pytest-faulthandler", "coverage", - "pycodestyle", - "pyflakes", "black", ], "docs": ["sphinx"],