diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..5316842b0 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +reformat: + black -l 99 `git ls-files "*.py"` +stylecheck: + black --check -l 99 `git ls-files "*.py"` diff --git a/make.bat b/make.bat new file mode 100644 index 000000000..b7b6ec9dc --- /dev/null +++ b/make.bat @@ -0,0 +1,30 @@ +@echo off + +if "%1"=="" goto help + +REM This allows us to expand variables at execution +setlocal ENABLEDELAYEDEXPANSION + +REM This will set PYFILES as a list of tracked .py files +set PYFILES= +for /F "tokens=* USEBACKQ" %%A in (`git ls-files "*.py"`) do ( + set PYFILES=!PYFILES! %%A +) + +goto %1 + +:reformat +black -l 99 !PYFILES! +exit /B %ERRORLEVEL% + +:stylecheck +black -l 99 --check !PYFILES! +exit /B %ERRORLEVEL% + +:help +echo Usage: +echo make ^ +echo. +echo Commands: +echo reformat Reformat all .py files being tracked by git. +echo stylecheck Check which tracked .py files need reformatting. diff --git a/tox.ini b/tox.ini index 2252a141e..ac7313560 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ envlist = py35 py36 docs - dev + style [testenv] description = Run unit tests with pytest @@ -31,7 +31,13 @@ commands = [testenv:style] description = Stylecheck the code with black to see if anything needs changes. +whitelist_externals = + make +setenv = + # This is just for Windows + # Prioritise make.bat over any make.exe which might be on PATH + PATHEXT=.BAT;.EXE basepython = python3.6 extras = style commands = - black -l 99 --check generate_strings.py setup.py tests redbot + make stylecheck