Fix pylint messages for repo

This commit is contained in:
erik 2023-04-28 14:41:37 +02:00
parent 0214cdd99a
commit 9db91c0a16

View file

@ -23,8 +23,7 @@ class VersionRepository:
def write_file(self, version_string): def write_file(self, version_string):
if self.file_handler is None: if self.file_handler is None:
raise Exception("Version was not created by load_file method.") raise RuntimeError("Version was not created by load_file method.")
else:
self.file_handler.write(version_string) self.file_handler.write(version_string)
def parse_file(self): def parse_file(self):
@ -53,28 +52,29 @@ class ReleaseTypeRepository:
@classmethod @classmethod
def from_git(cls, git_api: GitApi): def from_git(cls, git_api: GitApi):
releaseTypeRepo = cls(git_api=git_api) release_type_repo = cls(git_api=git_api)
releaseTypeRepo.get_from_git = True release_type_repo.get_from_git = True
return releaseTypeRepo return release_type_repo
@classmethod @classmethod
def from_environment(cls, environment_api: EnvironmentApi): def from_environment(cls, environment_api: EnvironmentApi):
releaseTypeRepo = cls(environment_api=environment_api) release_type_repo = cls(environment_api=environment_api)
releaseTypeRepo.get_from_env = True release_type_repo.get_from_env = True
return releaseTypeRepo return release_type_repo
def __get_release_type_git(self) -> ReleaseType | None: def __get_release_type_git(self) -> ReleaseType | None:
latest_commit = self.git_api.get_latest_commit() latest_commit = self.git_api.get_latest_commit()
if ReleaseType.MAJOR.name in latest_commit.upper(): match latest_commit.upper():
case ReleaseType.MAJOR.name:
return ReleaseType.MAJOR return ReleaseType.MAJOR
elif ReleaseType.MINOR.name in latest_commit.upper(): case ReleaseType.MINOR.name:
return ReleaseType.MINOR return ReleaseType.MINOR
elif ReleaseType.PATCH.name in latest_commit.upper(): case ReleaseType.PATCH.name:
return ReleaseType.PATCH return ReleaseType.PATCH
elif ReleaseType.SNAPSHOT.name in latest_commit.upper(): case ReleaseType.SNAPSHOT.name:
return ReleaseType.SNAPSHOT return ReleaseType.SNAPSHOT
else: case _:
return None return None
def __get_release_type_environment(self) -> ReleaseType | None: def __get_release_type_environment(self) -> ReleaseType | None:
@ -86,23 +86,24 @@ class ReleaseTypeRepository:
raise ValueError( raise ValueError(
"Release Name not found. Is the Environment correctly configured?" "Release Name not found. Is the Environment correctly configured?"
) )
elif ReleaseType.MAJOR.name in release_name.upper():
match release_name.upper():
case ReleaseType.MAJOR.name:
return ReleaseType.MAJOR return ReleaseType.MAJOR
elif ReleaseType.MINOR.name in release_name.upper(): case ReleaseType.MINOR.name:
return ReleaseType.MINOR return ReleaseType.MINOR
elif ReleaseType.PATCH.name in release_name.upper(): case ReleaseType.PATCH.name:
return ReleaseType.PATCH return ReleaseType.PATCH
elif ReleaseType.SNAPSHOT.name in release_name.upper(): case ReleaseType.SNAPSHOT.name:
return ReleaseType.SNAPSHOT return ReleaseType.SNAPSHOT
else: case _:
return None return None
def get_release_type(self) -> ReleaseType | None: def get_release_type(self) -> ReleaseType | None:
if self.get_from_git: if self.get_from_git:
return self.__get_release_type_git() return self.__get_release_type_git()
elif self.get_from_env: if self.get_from_env:
return self.__get_release_type_environment() return self.__get_release_type_environment()
else:
raise ValueError("No valid api passed to ReleaseTypeRepository") raise ValueError("No valid api passed to ReleaseTypeRepository")