diff --git a/doc/sphinx/development.rst b/doc/sphinx/development.rst
index 1db273da..067b8bfd 100644
--- a/doc/sphinx/development.rst
+++ b/doc/sphinx/development.rst
@@ -178,15 +178,23 @@ Hack, Hack, Hack
.. note::
- Follow the Style Guide, basically `PEP 8 `_.
+ Follow the Style Guide, basically `PEP 8 `_.
- We prefer to use double quotes and allow a max. line length of 99 characters.
+ Since version 3.x source formatting rules are delegated to the
+ `Black library `_.
Failing tests or not follwing PEP 8 will break builds on
`travis `_ and therefore be
- automatically rejected.
+ automatically rejected:
- Run ``$ flake8`` and ``$ tox`` frequently and before you commit!
+ - Run ``$ tox -e black`` to re-format the code, or
+ `look for plugins for your favorite editor `_
+ that format on-save.
+
+ - Run ``$ tox -e check`` frequently and before you commit.
+
+ - Don't forget to run ``$ tox`` to run the hole test suite before
+ you commit.
Test, Test, Test
diff --git a/tox.ini b/tox.ini
index a6a53cbe..a829f5ea 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
[tox]
basepython = python3.6
#envlist = clean, py27, py34, py35, stats
-envlist = black, py27, py34, py35, py36, py37
+envlist = check, py27, py34, py35, py36, py37
[testenv]
passenv = LC_ALL LANG TRAVIS TRAVIS_BRANCH TRAVIS_OS_NAME TRAVIS_BUILD_ID
@@ -27,16 +27,31 @@ deps =
requests
webtest
-[testenv:black]
+
+[testenv:check]
description = Check Black formatting compliance and add flake8-bugbear checks
basepython = python3.6
+changedir = {toxinidir}
+skip_install = true
deps =
black
flake8-bugbear
commands =
- black --check wsgidav tests
+ black --check --diff wsgidav tests
flake8 wsgidav tests
+
+[testenv:black]
+description = Reformat python code using Black
+basepython = python3.6
+changedir = {toxinidir}
+skip_install = true
+deps =
+ black
+commands =
+ black wsgidav tests
+
+
[testenv:docs]
description = Build Sphinx documentation (output directory: docs/sphinx-build)
basepython = python3.6
@@ -49,6 +64,7 @@ commands =
# http://www.sphinx-doc.org/en/master/man/sphinx-build.html
sphinx-build -b html sphinx sphinx-build
+
# [testenv:clean]
# commands =
# coverage erase
diff --git a/wsgidav/dav_provider.py b/wsgidav/dav_provider.py
index 43a7eaba..21423481 100644
--- a/wsgidav/dav_provider.py
+++ b/wsgidav/dav_provider.py
@@ -680,16 +680,10 @@ def get_property_value(self, name):
elif name.startswith("{DAV:}"):
# Standard live property (raises HTTP_NOT_FOUND if not supported)
- if (
- name == "{DAV:}creationdate"
- and self.get_creation_date() is not None
- ):
+ if name == "{DAV:}creationdate" and self.get_creation_date() is not None:
# Note: uses RFC3339 format (ISO 8601)
return util.get_rfc3339_time(self.get_creation_date())
- elif (
- name == "{DAV:}getcontenttype"
- and self.get_content_type() is not None
- ):
+ elif name == "{DAV:}getcontenttype" and self.get_content_type() is not None:
return self.get_content_type()
elif name == "{DAV:}resourcetype":
if self.is_collection:
@@ -698,8 +692,7 @@ def get_property_value(self, name):
return resourcetypeEL
return ""
elif (
- name == "{DAV:}getlastmodified"
- and self.get_last_modified() is not None
+ name == "{DAV:}getlastmodified" and self.get_last_modified() is not None
):
# Note: uses RFC1123 format
return util.get_rfc1123_time(self.get_last_modified())
@@ -711,9 +704,7 @@ def get_property_value(self, name):
return str(self.get_content_length())
elif name == "{DAV:}getetag" and self.get_etag() is not None:
return self.get_etag()
- elif (
- name == "{DAV:}displayname" and self.get_display_name() is not None
- ):
+ elif name == "{DAV:}displayname" and self.get_display_name() is not None:
return self.get_display_name()
# Unsupported, no persistence available, or property not found