make mypy green

This commit is contained in:
Michael Jerger 2023-05-20 15:40:27 +02:00
parent d5b75254b5
commit ce35bc2d54
6 changed files with 13 additions and 12 deletions

View file

@ -24,7 +24,7 @@ mypy:
stage: lint&test
script:
- pip install -r dev_requirements.txt
- python -m mypy src/main/python/ddadevops/ --ignore-missing-imports
- python -m mypy src/main/python/ddadevops/ --ignore-missing-imports --disable-error-code=attr-defined --disable-error-code=union-attr
pylint:
stage: lint&test

View file

@ -1,3 +1,4 @@
from pathlib import Path
from ..domain import Image, Devops, BuildType
from ..infrastructure import FileApi, ResourceApi, ImageApi
@ -19,7 +20,7 @@ class ImageBuildService:
def __copy_build_resource_file_from_package__(self, resource_name, devops: Devops):
data = self.resource_api.read_resource(f"src/main/resources/docker/{resource_name}")
self.file_api.write_data_to_file(
f"{devops.build_path()}/{resource_name}", data
Path(f"{devops.build_path()}/{resource_name}"), data
)
def __copy_build_resources_from_package__(self, devops: Devops):

View file

@ -1,7 +1,7 @@
import deprecation
from enum import Enum
from typing import List
from .common import Devops, BuildType, MixinType
from typing import List, Optional, Dict
from .common import Validateable, Devops, BuildType, MixinType
from .image import Image
from .c4k import C4k
from .release import Release
@ -12,17 +12,17 @@ class DevopsFactory:
def __init__(self):
pass
def build_devops(self, input: dict, version: Version = None) -> Devops:
def build_devops(self, input: dict, version: Optional[Version] = None) -> Devops:
build_types = self.__parse_build_types__(input["build_types"])
mixin_types = self.__parse_mixin_types__(input["mixin_types"])
specialized_builds = {}
specialized_builds: Dict[BuildType, Validateable] = {}
if BuildType.IMAGE in build_types:
specialized_builds[BuildType.IMAGE] = Image(input)
if BuildType.C4K in build_types:
specialized_builds[BuildType.C4K] = C4k(input)
mixins = {}
mixins: Dict[MixinType, Validateable] = {}
if MixinType.RELEASE in mixin_types:
mixins[MixinType.RELEASE] = Release(input, version)

View file

@ -1,7 +1,7 @@
from pathlib import Path
from typing import List
from typing import List, Dict
from .common import Devops, MixinType, BuildType
from .credentials import Credentials, GopassType
from .credentials import CredentialMapping, Credentials, GopassType
from .devops_factory import DevopsFactory
from .version import Version
from .release import ReleaseType
@ -110,7 +110,7 @@ class InitService:
return result
def authorization(self, credentials: Credentials) -> List[str]:
def authorization(self, credentials: Credentials) -> Dict[str, CredentialMapping]:
result = {}
for name in credentials.mappings.keys():
mapping = credentials.mappings[name]

View file

@ -12,7 +12,7 @@ from .version import (
class Release(Validateable):
def __init__(self, input: dict, version: Version):
def __init__(self, input: dict, version: Optional[Version]):
self.release_type = ReleaseType[input.get("release_type", "NONE")]
self.release_main_branch = input.get("release_main_branch", "main")
self.release_current_branch = input.get("release_current_branch")

View file

@ -60,7 +60,7 @@ class Version(Validateable):
]
return result
def create_bump(self, snapshot_suffix: str = None):
def create_bump(self, snapshot_suffix: Optional[str] = None):
new_version_list = self.version_list.copy()
if self.is_snapshot():
return Version(