1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-12-24 18:22:59 +00:00

missing/wrong type hints

This commit is contained in:
Jörn-Michael Miehe 2021-11-27 16:21:54 +01:00
parent 1c8f016208
commit e151562ab9
4 changed files with 11 additions and 11 deletions

View file

@ -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 "<variable>=<value>" 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:

View file

@ -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

View file

@ -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)

View file

@ -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',