summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xgitlab/description_parser.py20
-rwxr-xr-xgitlab/downloader.py6
-rwxr-xr-xgitlab/output.py8
3 files changed, 17 insertions, 17 deletions
diff --git a/gitlab/description_parser.py b/gitlab/description_parser.py
index 2615b6368..36b450bd4 100755
--- a/gitlab/description_parser.py
+++ b/gitlab/description_parser.py
@@ -1,29 +1,29 @@
-import re
+from re import sub, search, DOTALL
 from tomlkit import string
 
-def remove_comments(description):
-    return re.sub(r'<!--(.|\n)*?-->', '', description)
+def remove_comments(description : str) -> str:
+    return sub(r'<!--(.|\n)*?-->', '', description)
 
-def get_headline_content(description, headline):
+def get_headline_content(description : str, headline : str) -> str:
     pattern = rf'## {headline}\s+(.*?)(?=##\s|\Z)'
 
-    match = re.search(pattern, description, re.DOTALL)
+    match = search(pattern, description, DOTALL)
     if match:
-        return string(match.group(1).strip(), multiline=True)
+        return string(match.group(1).strip(), multiline = True)
     else:
         return "n/a"
 
-def get_bullet_point(description, headline, category):
+def get_bullet_point(description : str, headline : str, category : str) -> str:
     pattern = rf'{headline}(?:(?:.|\n)+?){category}:\s+(?:`)?(.+?)(?:`)?(?=\s)(?:\n|$)'
 
-    match = re.search(pattern, description)
+    match = search(pattern, description)
     if match:
         return match.group(1).strip()
     else:
         return "n/a"
 
-def parse_description(desc):
-    desc = remove_comments(desc)
+def parse_description(description : str) -> dict:
+    desc = remove_comments(description)
 
     result = {
         "host-os": get_bullet_point(desc, "Host", "Operating system"),
diff --git a/gitlab/downloader.py b/gitlab/downloader.py
index 2b73f1cf5..89c37d46b 100755
--- a/gitlab/downloader.py
+++ b/gitlab/downloader.py
@@ -1,4 +1,4 @@
-from requests import get
+from requests import get, Response
 from description_parser import parse_description
 from output import output_issue
 
@@ -6,7 +6,7 @@ project_id = 11167699
 per_page = 100
 url = f"https://gitlab.com/api/v4/projects/{project_id}/issues?per_page={per_page}"
 
-def pages_iterator(first):
+def pages_iterator(first : Response):
     current = first
     while current.links.get('next'):
         current.raise_for_status()
@@ -16,7 +16,7 @@ def pages_iterator(first):
     yield current
 
 def main():
-    for response in pages_iterator(get(url = url)):
+    for response in pages_iterator(get(url)):
         print(f"Current page: {response.headers['x-page']}")
 
         data = response.json()
diff --git a/gitlab/output.py b/gitlab/output.py
index 745081aef..07293147b 100755
--- a/gitlab/output.py
+++ b/gitlab/output.py
@@ -1,18 +1,18 @@
 from tomlkit import dumps
 from os import path, makedirs
 
-def find_label(labels, keyword):
+def find_label(labels : list, keyword : str) -> str:
     match = next((s for s in labels if f"{keyword}:" in s), None)
     if not match:
         return f"{keyword}_missing"
     return match.replace(": ", "_")
 
-def write_file(file_path, string):
-    makedirs(path.dirname(file_path), exist_ok=True)
+def write_file(file_path : str, string : str) -> None:
+    makedirs(path.dirname(file_path), exist_ok = True)
     with open(file_path, "w") as file:
         file.write(string)
 
-def output_issue(issue):
+def output_issue(issue : dict) -> None:
     labels = issue['labels']
     issue_id = issue['id']
     toml_string = dumps(issue)