Merge pull request #63 from askpatrickw/black-and-pylint
Black and pylint Suport in dev environment
This commit is contained in:
commit
14be02048b
4 changed files with 26 additions and 36 deletions
17
Makefile
17
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..."
|
||||
|
|
|
|||
39
make/make.py
39
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:
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@ packaging==19.1
|
|||
pkginfo==1.5.0.1
|
||||
pluggy==0.13.1
|
||||
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
|
||||
|
|
|
|||
3
setup.py
3
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"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue