From 2df11674c426e5587568828bb39ba14f2766b0e9 Mon Sep 17 00:00:00 2001 From: BugFest Date: Sun, 9 Apr 2023 19:05:15 +0200 Subject: [PATCH] Fixes #661 - Fixes linting/flake8 errors Signed-off-by: BugFest --- examples/hello-python/App/web.py | 2 +- podman_compose.py | 38 ++++++++++++++++++++++++-------- setup.cfg | 4 ++++ setup.py | 2 +- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/examples/hello-python/App/web.py b/examples/hello-python/App/web.py index 25c584e..e49958c 100644 --- a/examples/hello-python/App/web.py +++ b/examples/hello-python/App/web.py @@ -1,5 +1,5 @@ import os -import asyncio +import asyncio # noqa: F401 import aioredis from aiohttp import web diff --git a/podman_compose.py b/podman_compose.py index e3532ba..d0125ae 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -43,11 +43,23 @@ __version__ = "1.0.7" script = os.path.realpath(sys.argv[0]) # helper functions -is_str = lambda s: isinstance(s, str) -is_dict = lambda d: isinstance(d, dict) -is_list = lambda l: not is_str(l) and not is_dict(l) and hasattr(l, "__iter__") + + +def is_str(string_object): + return isinstance(string_object, str) + + +def is_dict(dict_object): + return isinstance(dict_object, dict) + + +def is_list(list_object): + return not is_str(list_object) and not is_dict(list_object) and hasattr(list_object, "__iter__") + + # identity filter -filteri = lambda a: filter(lambda i: i, a) +def filteri(a): + return filter(lambda i: i, a) def try_int(i, fallback=None): @@ -797,7 +809,9 @@ def get_net_args(compose, cnt): cnt_nets = cnt.get("networks", None) aliases = [service_name] # NOTE: from podman manpage: - # NOTE: A container will only have access to aliases on the first network that it joins. This is a limitation that will be removed in a later release. + # NOTE: A container will only have access to aliases on the first network + # that it joins. This is a limitation that will be removed in a later + # release. ip = None ip6 = None if cnt_nets and is_dict(cnt_nets): @@ -1127,7 +1141,11 @@ class Podman: log(" ".join([str(i) for i in cmd_ls])) if self.dry_run: return None - # subprocess.Popen(args, bufsize = 0, executable = None, stdin = None, stdout = None, stderr = None, preexec_fn = None, close_fds = False, shell = False, cwd = None, env = None, universal_newlines = False, startupinfo = None, creationflags = 0) + # subprocess.Popen( + # args, bufsize = 0, executable = None, stdin = None, stdout = None, stderr = None, preexec_fn = None, + # close_fds = False, shell = False, cwd = None, env = None, universal_newlines = False, startupinfo = None, + # creationflags = 0 + # ) if log_formatter is not None: # Pipe podman process output through log_formatter (which can add colored prefix) p = subprocess.Popen( @@ -1799,7 +1817,7 @@ def is_local(container: dict) -> bool: * has a build section and is not prefixed """ return ( - not "/" in container["image"] + "/" not in container["image"] if "build" in container else container["image"].startswith("localhost/") ) @@ -2522,7 +2540,8 @@ def compose_up_parse(parser): "-d", "--detach", action="store_true", - help="Detached mode: Run container in the background, print new container name. Incompatible with --abort-on-container-exit.", + help="Detached mode: Run container in the background, print new container name. \ + Incompatible with --abort-on-container-exit.", ) parser.add_argument( "--no-color", action="store_true", help="Produce monochrome output." @@ -2573,7 +2592,8 @@ def compose_up_parse(parser): "--timeout", type=int, default=None, - help="Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)", + help="Use this timeout in seconds for container shutdown when attached or when containers are already running. \ + (default: 10)", ) parser.add_argument( "-V", diff --git a/setup.cfg b/setup.cfg index e900d2f..62c97c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,7 @@ universal = 1 [metadata] version = attr: podman_compose.__version__ + +[flake8] +# The GitHub editor is 127 chars wide +max-line-length=127 \ No newline at end of file diff --git a/setup.py b/setup.py index 4b3f2d1..edfdf9f 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup try: readme = open(os.path.join(os.path.dirname(__file__), "README.md")).read() -except: +except: # noqa: E722 readme = "" setup(