diff options
author | peppepetra86 <giuseppe.petralia@canonical.com> | 2020-08-10 15:28:55 +0200 |
---|---|---|
committer | peppepetra86 <giuseppe.petralia@canonical.com> | 2020-08-10 15:28:55 +0200 |
commit | ca8264bd14135b0087696d5c17e0913360a011a7 (patch) | |
tree | e15da2cbc06f9591e9839476faf1b9fc9b64ab15 | |
parent | 72600b40487520a13e23bbee27b812c62825adab (diff) |
Fix linting
-rw-r--r-- | Makefile | 14 | ||||
-rwxr-xr-x | hooks/hooks.py | 6 | ||||
-rw-r--r-- | tox.ini | 6 |
3 files changed, 19 insertions, 7 deletions
@@ -16,7 +16,8 @@ help: @echo " make submodules-update - update submodules to latest changes on remote branch" @echo " make build - build the charm" @echo " make release - run clean and build targets" - @echo " make lint - run flake8 and black" + @echo " make lint - run flake8 and black --check" + @echo " make black - run black and reformat files" @echo " make proof - run charm proof" @echo " make unittests - run the tests defined in the unittest subdirectory" @echo " make functional - run the tests defined in the functional subdirectory" @@ -25,7 +26,7 @@ help: clean: @echo "Cleaning files" - @git clean -fXd + @git clean -ffXd -e '!.idea' @echo "Cleaning existing build" @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME} @@ -39,7 +40,8 @@ submodules-update: build: @echo "Building charm to base directory ${CHARM_BUILD_DIR}/${CHARM_NAME}" - @-git describe --tags > ./repo-info + @-git rev-parse --abbrev-ref HEAD > ./repo-info + @-git describe --always > ./version @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME} @cp -a ./* ${CHARM_BUILD_DIR}/${CHARM_NAME} @@ -50,6 +52,10 @@ lint: @echo "Running lint checks" @tox -e lint +black: + @echo "Reformat files with black" + @tox -e black + proof: @echo "Running charm proof" @-charm proof @@ -66,4 +72,4 @@ test: lint proof unittests functional @echo "Charm ${CHARM_NAME} has been tested" # The targets below don't depend on a file -.PHONY: help submodules submodules-update clean build release lint proof unittests functional test +.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test diff --git a/hooks/hooks.py b/hooks/hooks.py index 0c43ce5..fe10847 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -273,7 +273,7 @@ class TimeoutException(Exception): ############################################################################### # Charm support functions ############################################################################### -def mongodb_conf(config_data=None): # noqa: C901 +def mongodb_conf(config_data=None): # noqa C901 if config_data is None: return None config = [] @@ -950,8 +950,8 @@ def install_hook(): apt_install(packages=INSTALL_PACKAGES, fatal=True) -@hooks.hook("config-changed") -def config_changed(): # noqa: C901 +@hooks.hook("config-changed") # noqa C901 +def config_changed(): # noqa C901 juju_log("Entering config_changed") status_set("maintenance", "Configuring unit") config_data = config() @@ -50,6 +50,12 @@ exclude = max-line-length = 88 max-complexity = 10 +[testenv:black] +commands = + black --exclude "/(\.eggs|\.git|\.tox|\.venv|\.build|dist|charmhelpers|mod)/" . +deps = + black + [testenv:unit] commands = coverage run -m unittest discover -s {toxinidir}/tests/unit -v |