Skip to content

Commit

Permalink
test strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Becker committed Jun 12, 2024
1 parent 19d5cd7 commit ae6cb9e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
26 changes: 13 additions & 13 deletions pipeline/GitCommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class GitCommit:
commit_link_url(str): Link zum Commit bei GitHub/Lab
test_report_link_url(str): Link zum Unittest Report bei GitHub/Lab
'''
def __init__(self, branch_name, commit_hash, commit_message,
image_name, project_url, pipeline_id, pipeline_link_url,
commit_link_url, test_report_link_url):
def __init__(self, branch_name: str, commit_hash: str, commit_message: str,
image_name: str, project_url: str, pipeline_id: str, pipeline_link_url: str,
commit_link_url: str, test_report_link_url: str):
self.branch_name = branch_name
self.commit_hash = commit_hash
self.commit_message = commit_message
Expand All @@ -38,7 +38,7 @@ def __init__(self, branch_name, commit_hash, commit_message,
self.test_report_link_url = test_report_link_url

@staticmethod
def check_source_system():
def check_source_system() -> str:
'''
Diese Funktion überprüft, ob es sich um GitLab oder GitHub handelt.
'''
Expand All @@ -48,55 +48,55 @@ def check_source_system():
return 'Gitlab'
raise GitException('Source system not recognized.')

def get_branch_name(self):
def get_branch_name(self) -> str:
'''
Gibt den Namen des momentanen Branches zurück.
'''
return self.branch_name

def get_commit_hash(self):
def get_commit_hash(self) -> str:
'''
Gibt den Hashwert des aktuellen Commits zurück.
'''
return self.commit_hash

def get_commit_message(self):
def get_commit_message(self) -> str:
'''
Gibt die Commit Nachricht zurück.
'''
return self.commit_message

def get_image_name(self):
def get_image_name(self) -> str:
'''
Gibt den Namen des zukünftigen Docker Images zurück.
'''
return self.image_name

def get_project_url(self):
def get_project_url(self) -> str:
'''
Gibt die URL zum GitLab Projekt (Repository) zurück
'''
return self.project_url

def get_pipeline_id(self):
def get_pipeline_id(self) -> str:
'''
Gibt die ID der aktuellen Pipeline zurück.
'''
return self.pipeline_id

def get_pipeline_link_url(self):
def get_pipeline_link_url(self) -> str:
'''
Gibt den Link zur aktuellen Pipeline zurück.
'''
return self.pipeline_link_url

def get_commit_link_url(self):
def get_commit_link_url(self) -> str:
'''
Gibt den Link zum aktuellen Commit zurück.
'''
return self.commit_link_url

def get_test_report_link_url(self):
def get_test_report_link_url(self) -> str:
'''
Gibt den Link zum Unit Test Report zurück.
'''
Expand Down
10 changes: 5 additions & 5 deletions pipeline/TrelloBoard.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TrelloBoard:
api_key (str): API Key zur Authentifizierung
api_token (str): API Token zur Authentifzierung
'''
def __init__(self, board_id=None, api_key=None, api_token=None):
def __init__(self, board_id: str = None, api_key: str = None, api_token: str = None):
self.board_id = board_id if board_id is not None \
else os.environ.get('TRELLO_BOARD_ID')
self.api_key = api_key if api_key is not None \
Expand All @@ -27,7 +27,7 @@ def __init__(self, board_id=None, api_key=None, api_token=None):
else os.environ.get('TRELLO_API_TOKEN')
self.board_lists = self.__query_lists_in_board()

def get_board_lists(self):
def get_board_lists(self) -> dict:
'''
Gibt alle Listen im Trello Board zurück.
Expand All @@ -37,8 +37,8 @@ def get_board_lists(self):
'''
return self.board_lists

def query_trello_api(self, url, params=None, method='GET',
file_blob=None, timeout=10):
def query_trello_api(self, url: str, params: dict = None, method: str = 'GET',
file_blob: any = None, timeout: int = 10) -> dict:
'''
Wrapper für die GET API Requests an die Trello REST API
'''
Expand Down Expand Up @@ -78,7 +78,7 @@ def query_trello_api(self, url, params=None, method='GET',
raise TrelloException(error_message)
return json.loads(response.text)

def __query_lists_in_board(self):
def __query_lists_in_board(self) -> dict:
'''
Diese Funktion gibt alle Listen inklusive der IDs innerhalb des
Trello Boards zurück
Expand Down
12 changes: 6 additions & 6 deletions pipeline/TrelloTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TrelloTask(TrelloBoard):
gitlab_project_url (str): URL zum Projekt in von Gitlab
gitlab_image_name (str): Name des Docker Images in Gitlab
'''
def __init__(self, git_commit):
def __init__(self, git_commit: GitCommit):
super().__init__()
self.git_commit = git_commit
self.task = self.__get_task()
Expand Down Expand Up @@ -120,8 +120,8 @@ def intra_feature_branch_pipeline(self):
# self.__upload_attachment('gl-container-scanning-report.json')
# self.__upload_attachment('gl-sbom-report.cdx.json')

def post_feature_branch_pipeline(self, is_review_failed,
is_pipeline_failed):
def post_feature_branch_pipeline(self, is_review_failed: bool,
is_pipeline_failed: bool):
'''
Diese Funktion wird aufgerufen wenn die Review Pipelines enden.
Folgende Dinge passieren hier:
Expand Down Expand Up @@ -186,7 +186,7 @@ def pre_production_pipeline(self):
'''
self.__add_new_comment(card_comment_text)

def post_production_pipeline(self, is_failed):
def post_production_pipeline(self, is_failed: bool) -> None:
'''
Diese Funktion wird aufgerufen wenn die Review Pipelines starten.
Folgende Dinge passieren hier:
Expand Down Expand Up @@ -219,7 +219,7 @@ def post_production_pipeline(self, is_failed):
'''
self.__add_new_comment(card_comment_text)

def __add_new_comment(self, text):
def __add_new_comment(self, text: str):
'''
Mit dieser Funktion wird ein neuer Kommentar zu einer Card hinzugefügt.
'''
Expand All @@ -229,7 +229,7 @@ def __add_new_comment(self, text):
}
return self.query_trello_api(url, params, 'POST')

def __move_card_to(self, list_name):
def __move_card_to(self, list_name: str):
'''
Mit dieser Funktion wird die Karte in eine neue Spalte verschoben.
'''
Expand Down

0 comments on commit ae6cb9e

Please sign in to comment.