From 2e34d75e64628d02e32dadaa87bfa35447fa503c Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 13 Jul 2020 14:53:41 +0200 Subject: [PATCH] Prepare auto-formatting with black (#364) Also removes autopep8 and prepares configuration for import sorter isort. Signed-off-by: Christian Heimes --- Doc/contributing.rst | 2 +- Makefile | 14 ++++++++------ pyproject.toml | 8 ++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 pyproject.toml diff --git a/Doc/contributing.rst b/Doc/contributing.rst index b11c18b..1fc1365 100644 --- a/Doc/contributing.rst +++ b/Doc/contributing.rst @@ -108,7 +108,7 @@ Notable targets are: Note that no backups are made – please commit any other changes before using this target. - Requires the ``indent`` program and the ``autopep8`` Python module. + Requires the ``indent`` program and the ``black`` Python module. .. _PEP 7: https://www.python.org/dev/peps/pep-0007/ .. _PEP 8: https://www.python.org/dev/peps/pep-0008/ diff --git a/Makefile b/Makefile index 8ec46a6..f7360a6 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ LCOV_REPORT_OPTIONS=--show-details -no-branch-coverage \ --title "python-ldap LCOV report" SCAN_REPORT=build/scan_report PYTHON_SUPP=/usr/share/doc/python3-devel/valgrind-python.supp -AUTOPEP8_OPTS=--aggressive + .NOTPARALLEL: @@ -85,13 +85,15 @@ valgrind: build $(PYTHON_SUPP) fi # Code autoformatter -.PHONY: autoformat indent autopep8 -autoformat: indent autopep8 +.PHONY: autoformat indent black black-check +autoformat: indent black indent: indent Modules/*.c Modules/*.h rm -f Modules/*.c~ Modules/*.h~ -autopep8: - $(PYTHON) -m autopep8 -r -i -j0 $(AUTOPEP8_OPTS) \ - Demo Lib Tests setup.py +black: + $(PYTHON) -m black $(CURDIR) + +black-check: + $(PYTHON) -m black $(CURDIR) --check diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dda8dbc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[tool.black] +line-length = 88 +target-version = ['py36', 'py37', 'py38'] + +[tool.isort] +line_length=88 +known_first_party=['ldap', '_ldap', 'ldapurl', 'ldif', 'slapdtest'] +sections=['FUTURE', 'STDLIB', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER']