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