Skip to content

Prepare auto-formatting with black #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool.black]
line-length = 88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this needs to be specified, why not stick to PEP 8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

88 is the default line length for black. I'm mentioning 88 here to make the line length setting explicit.

target-version = ['py36', 'py37', 'py38']

[tool.isort]
line_length=88
known_first_party=['ldap', '_ldap', 'ldapurl', 'ldif', 'slapdtest']
sections=['FUTURE', 'STDLIB', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER']