diff options
author | Shreenidhi Shedi <53473811+sshedi@users.noreply.github.com> | 2021-09-01 19:53:55 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 09:23:55 -0500 |
commit | 58c2de4c97de6cfa6edbf5319641f2ef71284895 (patch) | |
tree | 3f8806eeb1e61a408f85f48b9a07d85b981acf50 | |
parent | 76cff793840be63a69a74293170122c189ebaead (diff) | |
download | vyos-cloud-init-58c2de4c97de6cfa6edbf5319641f2ef71284895.tar.gz vyos-cloud-init-58c2de4c97de6cfa6edbf5319641f2ef71284895.zip |
Fix `make style-check` errors (#1000)
Using flake8 inplace of pyflakes
Renamed run-pyflakes -> run-flake8
Changed target name to flake8 in Makefile
With pyflakes we can't suppress warnings/errors in few required places.
flake8 is flexible in that regard. Hence using flake8 seems to be a
better choice here.
flake8 does the job of pep8 anyway.
So, removed pep8 target from Makefile along with tools/run-pep8 script.
Included setup.py in flake8 checks
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | cloudinit/cmd/devel/hotplug_hook.py | 3 | ||||
-rwxr-xr-x | cloudinit/distros/__init__.py | 2 | ||||
-rw-r--r-- | cloudinit/sources/__init__.py | 2 | ||||
-rw-r--r-- | cloudinit/stages.py | 2 | ||||
-rwxr-xr-x | setup.py | 8 | ||||
-rw-r--r-- | tests/integration_tests/clouds.py | 2 | ||||
-rw-r--r-- | tests/integration_tests/instances.py | 4 | ||||
-rwxr-xr-x | tools/run-flake8 (renamed from tools/run-pyflakes) | 4 | ||||
-rwxr-xr-x | tools/run-pep8 | 21 | ||||
-rw-r--r-- | tox.ini | 4 |
11 files changed, 23 insertions, 40 deletions
@@ -18,13 +18,10 @@ all: check check: check_version test yaml -style-check: pep8 $(pyflakes) +style-check: flake8 -pep8: - @$(CWD)/tools/run-pep8 - -pyflakes: - @$(CWD)/tools/run-pyflakes +flake8: + @$(CWD)/tools/run-flake8 unittest: clean_pyc python3 -m pytest -v tests/unittests cloudinit @@ -86,6 +83,6 @@ deb-src: doc: tox -e doc -.PHONY: test pyflakes clean pep8 rpm srpm deb deb-src yaml +.PHONY: test flake8 clean rpm srpm deb deb-src yaml .PHONY: check_version pip-test-requirements pip-requirements clean_pyc .PHONY: unittest style-check doc diff --git a/cloudinit/cmd/devel/hotplug_hook.py b/cloudinit/cmd/devel/hotplug_hook.py index a0058f03..d4f0547e 100644 --- a/cloudinit/cmd/devel/hotplug_hook.py +++ b/cloudinit/cmd/devel/hotplug_hook.py @@ -13,7 +13,8 @@ from cloudinit.net import activators, read_sys_net_safe from cloudinit.net.network_state import parse_net_config_data from cloudinit.reporting import events from cloudinit.stages import Init -from cloudinit.sources import DataSource, DataSourceNotFoundException +from cloudinit.sources import DataSource # noqa: F401 +from cloudinit.sources import DataSourceNotFoundException LOG = log.getLogger(__name__) diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index a634623a..2e629143 100755 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -16,7 +16,7 @@ import stat import string import urllib.parse from io import StringIO -from typing import Any, Mapping +from typing import Any, Mapping # noqa: F401 from cloudinit import importer from cloudinit import log as logging diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index cc7e1c3c..54b8240a 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -13,7 +13,7 @@ import copy import json import os from collections import namedtuple -from typing import Dict, List +from typing import Dict, List # noqa: F401 from cloudinit import dmi from cloudinit import importer diff --git a/cloudinit/stages.py b/cloudinit/stages.py index bc164fa0..80aa9f5e 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -9,7 +9,7 @@ import os import pickle import sys from collections import namedtuple -from typing import Dict, Set +from typing import Dict, Set # noqa: F401 from cloudinit.settings import ( FREQUENCIES, CLOUD_CONFIG, PER_INSTANCE, PER_ONCE, RUN_CLOUD_CONFIG) @@ -28,9 +28,11 @@ import subprocess RENDERED_TMPD_PREFIX = "RENDERED_TEMPD" VARIANT = None + def is_f(p): return os.path.isfile(p) + def is_generator(p): return '-generator' in p @@ -111,6 +113,7 @@ def render_tmpl(template, mode=None): # return path relative to setup.py return os.path.join(os.path.basename(tmpd), bname) + # User can set the variant for template rendering if '--distro' in sys.argv: idx = sys.argv.index('--distro') @@ -166,7 +169,7 @@ elif os.path.isfile('/etc/system-release-cpe'): with open('/etc/system-release-cpe') as f: cpe_data = f.read().rstrip().split(':') - if cpe_data[1] == "\o": + if cpe_data[1] == "\o": # noqa: W605 # URI formated CPE inc = 0 else: @@ -216,7 +219,8 @@ class InitsysInstallData(install): if self.init_system and isinstance(self.init_system, str): self.init_system = self.init_system.split(",") - if len(self.init_system) == 0 and not platform.system().endswith('BSD'): + if (len(self.init_system) == 0 and + not platform.system().endswith('BSD')): self.init_system = ['systemd'] bad = [f for f in self.init_system if f not in INITSYS_TYPES] diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py index f2362b5d..32fdc91e 100644 --- a/tests/integration_tests/clouds.py +++ b/tests/integration_tests/clouds.py @@ -28,7 +28,7 @@ from tests.integration_tests.instances import ( from tests.integration_tests.util import emit_dots_on_travis try: - from typing import Optional + from typing import Optional # noqa: F401 except ImportError: pass diff --git a/tests/integration_tests/instances.py b/tests/integration_tests/instances.py index 055ec758..63e0e630 100644 --- a/tests/integration_tests/instances.py +++ b/tests/integration_tests/instances.py @@ -13,7 +13,9 @@ from tests.integration_tests import integration_settings try: from typing import TYPE_CHECKING if TYPE_CHECKING: - from tests.integration_tests.clouds import IntegrationCloud + from tests.integration_tests.clouds import ( # noqa: F401 + IntegrationCloud + ) except ImportError: pass diff --git a/tools/run-pyflakes b/tools/run-flake8 index 179afebe..0021cdb9 100755 --- a/tools/run-pyflakes +++ b/tools/run-flake8 @@ -2,7 +2,7 @@ CR=" " -pycheck_dirs=( "cloudinit/" "tests/" "tools/" ) +pycheck_dirs=( "cloudinit/" "tests/" "tools/" "setup.py" ) set -f if [ $# -eq 0 ]; then @@ -11,7 +11,7 @@ else files=( "$@" ) fi -cmd=( "python3" -m "pyflakes" "${files[@]}" ) +cmd=( "python3" -m "flake8" "${files[@]}" ) echo "Running: " "${cmd[@]}" 1>&2 exec "${cmd[@]}" diff --git a/tools/run-pep8 b/tools/run-pep8 deleted file mode 100755 index 4bd0bbfb..00000000 --- a/tools/run-pep8 +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -pycheck_dirs=( "cloudinit/" "tests/" "tools/" ) - -CR=" -" -[ "$1" = "-v" ] && { verbose="$1"; shift; } || verbose="" - -set -f -if [ $# -eq 0 ]; then unset IFS - IFS="$CR" - files=( "${bin_files[@]}" "${pycheck_dirs[@]}" ) - unset IFS -else - files=( "$@" ) -fi - -myname=${0##*/} -cmd=( "${myname#run-}" $verbose "${files[@]}" ) -echo "Running: " "${cmd[@]}" 1>&2 -exec "${cmd[@]}" @@ -13,7 +13,7 @@ passenv= basepython = python3 deps = flake8==3.8.2 -commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/} +commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} # https://github.com/gabrielfalcao/HTTPretty/issues/223 setenv = @@ -119,7 +119,7 @@ deps = pytest==3.0.7 [testenv:tip-flake8] -commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/} +commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} deps = flake8 [testenv:tip-pylint] |