From ac810054aa1318a96eb24bf3428261909303ee4b Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Sun, 15 Sep 2019 21:02:40 -0700 Subject: [PATCH] Add auto-formatting via black Introduce black, a Python code formatter. Also a Makefile that includes two common targets: * fmt (auto-format the code) * lint (lint the code and return non-zero if out of spec) We can re-use the latter in CI. By introducing a code formatter, we can cut down on stylistic variations across a now-large codebase. We can also avoid most style discussions in PR if we just have this thing enforce it for us. --- Makefile | 12 ++++++++++++ requirements.txt | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..450c30c9b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +default: install + +BLACK_FORMAT_CONFIGS = --target-version py37 --line-length 100 + +install: + python setup.py develop + +fmt: + black $(BLACK_FORMAT_CONFIGS) evennia + +lint: + black --check $(BLACK_FORMAT_CONFIGS) evennia diff --git a/requirements.txt b/requirements.txt index cc23261fa1..cfbf6e5af3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,9 +9,10 @@ inflect autobahn >= 17.9.3 model_mommy -# testing +# testing and development mock >= 1.0.1 anything +black # windows-specific pypiwin32;platform_system=="Windows"