From e151562ab9bd0c3596118bb737bd2ee51cdee534 Mon Sep 17 00:00:00 2001 From: ldericher <40151420+ldericher@users.noreply.github.com> Date: Sat, 27 Nov 2021 16:21:54 +0100 Subject: [PATCH] missing/wrong type hints --- kiwi_scp/config.py | 14 +++++++------- kiwi_scp/instance.py | 2 +- kiwi_scp/misc.py | 2 +- kiwi_scp/rootkit.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kiwi_scp/config.py b/kiwi_scp/config.py index e78b6cd..08c4a3a 100644 --- a/kiwi_scp/config.py +++ b/kiwi_scp/config.py @@ -1,7 +1,7 @@ import functools from ipaddress import IPv4Network from pathlib import Path -from typing import Optional, Dict, List, Any, TextIO +from typing import Optional, Dict, List, Any, TextIO, Tuple from pydantic import BaseModel, constr, root_validator, validator @@ -55,7 +55,7 @@ class ProjectConfig(BaseModel): @validator("override_storage", pre=True) @classmethod - def unify_storage(cls, value): + def unify_storage(cls, value) -> Dict[str, Any]: """parse different storage notations""" if value is None or isinstance(value, dict): @@ -135,7 +135,7 @@ class KiwiConfig(BaseModel): @classmethod @functools.lru_cache(maxsize=5) - def from_directory(cls, directory: Path): + def from_directory(cls, directory: Path) -> "KiwiConfig": """parses an actual kiwi.yml from disk (cached)""" try: @@ -148,7 +148,7 @@ class KiwiConfig(BaseModel): @classmethod @functools.lru_cache(maxsize=1) - def from_default(cls): + def from_default(cls) -> "KiwiConfig": """returns the default config (cached)""" return cls() @@ -268,7 +268,7 @@ class KiwiConfig(BaseModel): def unify_environment(cls, value) -> Dict[str, Optional[str]]: """parse different environment notations""" - def parse_str(var_val: Any) -> (str, Optional[str]): + def parse_str(var_val: Any) -> Tuple[str, Optional[str]]: """parse a "=" string""" try: @@ -311,7 +311,7 @@ class KiwiConfig(BaseModel): @validator("storage", pre=True) @classmethod - def unify_storage(cls, value): + def unify_storage(cls, value) -> Dict[str, Any]: """parse different storage notations""" if value is None: @@ -336,7 +336,7 @@ class KiwiConfig(BaseModel): @validator("network", pre=True) @classmethod - def unify_network(cls, value): + def unify_network(cls, value) -> Dict[str, Any]: """parse different network notations""" if value is None: diff --git a/kiwi_scp/instance.py b/kiwi_scp/instance.py index 84f7c22..7b358b0 100644 --- a/kiwi_scp/instance.py +++ b/kiwi_scp/instance.py @@ -46,7 +46,7 @@ class Services: def __bool__(self) -> bool: return bool(self.content) - def filter_existing(self, service_names: List[str]): + def filter_existing(self, service_names: List[str]) -> "Services": return Services([ service for service in self.content diff --git a/kiwi_scp/misc.py b/kiwi_scp/misc.py index eb2ad3b..b38d4a0 100644 --- a/kiwi_scp/misc.py +++ b/kiwi_scp/misc.py @@ -23,7 +23,7 @@ class YAML(ruamel.yaml.YAML): return stream.getvalue() @staticmethod - def _format_kiwi_yml(yml_string: str): + def _format_kiwi_yml(yml_string: str) -> str: # insert newline before every main key yml_string = re.sub(r'^(\S)', r'\n\1', yml_string, flags=re.MULTILINE) diff --git a/kiwi_scp/rootkit.py b/kiwi_scp/rootkit.py index adef3f1..c1a42da 100644 --- a/kiwi_scp/rootkit.py +++ b/kiwi_scp/rootkit.py @@ -67,9 +67,9 @@ class Rootkit: f"{IMAGES_DIRECTORY_NAME}" ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - def run(self, process_args, **kwargs): + def run(self, process_args, **kwargs) -> Optional[subprocess.CompletedProcess]: self.__build_image() - DOCKER_EXE.run([ + return DOCKER_EXE.run([ 'run', '--rm', '-v', '/:/mnt', '-u', 'root',