Skip to content

Commit

Permalink
Add some missing return type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Jun 23, 2024
1 parent 3b76683 commit 4449b32
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bugme.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def print_issues( # pylint: disable=too-many-arguments
print("</tbody></table>")


def main():
def main() -> None:
"""
Main function
"""
Expand Down
8 changes: 4 additions & 4 deletions services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ class Service(ABC):
Service class to abstract methods
"""

def __init__(self, url: str):
def __init__(self, url: str) -> None:
url = url.rstrip("/")
self.url = url if url.startswith("https://") else f"https://{url}"
self.tag = "".join([s[0] for s in str(urlparse(self.url).hostname).split(".")])

@abstractmethod
def close(self):
def close(self) -> None:
"""
Close session
"""
Expand Down Expand Up @@ -234,7 +234,7 @@ class Generic(Service):
Generic class for services using python requests
"""

def __init__(self, url: str, token: str | None):
def __init__(self, url: str, token: str | None) -> None:
super().__init__(url)
self.issue_api_url = self.pr_api_url = "OVERRIDE"
self.issue_web_url = self.pr_web_url = "OVERRIDE"
Expand Down Expand Up @@ -323,7 +323,7 @@ def get_page(page: int) -> list[dict[str, Any]]:
)
return entries

def close(self):
def close(self) -> None:
self.session.close()

def get_issue(self, issue_id: str = "", **kwargs) -> Issue | None:
Expand Down
4 changes: 2 additions & 2 deletions services/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MyBugzilla(Service):
Bugzilla
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url)
options = {
# "force_rest": True,
Expand All @@ -41,7 +41,7 @@ def __init__(self, url: str, creds: dict):
if path:
self.url = f"{self.url}/bugzilla"

def close(self):
def close(self) -> None:
try:
self.client.disconnect()
except (AttributeError, BugzillaError):
Expand Down
2 changes: 1 addition & 1 deletion services/gitea.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MyGitea(Generic):
Gitea
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url, token=creds.get("token"))
self.issue_api_url = f"{self.url}/api/v1/repos/{{repo}}/issues/{{issue}}"
self.issue_web_url = f"{self.url}/{{repo}}/issues/{{issue}}"
Expand Down
4 changes: 2 additions & 2 deletions services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MyGithub(Service):
Github
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url)
options: dict[str, Any] = {
# NOTE: Uncomment when latest PyGithub is published on Tumbleweed
Expand All @@ -34,7 +34,7 @@ def __init__(self, url: str, creds: dict):
if os.getenv("DEBUG"):
logging.getLogger("github").setLevel(logging.DEBUG)

def close(self):
def close(self) -> None:
try:
self.client.close()
except (AttributeError, GithubException):
Expand Down
4 changes: 2 additions & 2 deletions services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MyGitlab(Service):
Gitlab
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url)
options: dict[str, Any] = {
"ssl_verify": os.environ.get("REQUESTS_CA_BUNDLE", True),
Expand All @@ -40,7 +40,7 @@ def __init__(self, url: str, creds: dict):
except (GitlabError, RequestException):
pass

def close(self):
def close(self) -> None:
try:
self.client.session.close()
except (AttributeError, GitlabError):
Expand Down
4 changes: 2 additions & 2 deletions services/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class MyJira(Service):
Jira
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url)
self.client = Jira(url=self.url, **creds)
self.client._session.headers["User-Agent"] = f"bugme/{VERSION}"
if os.getenv("DEBUG"):
self.client._session.hooks["response"].append(debugme)

def close(self):
def close(self) -> None:
try:
self.client.session.close()
except AttributeError:
Expand Down
2 changes: 1 addition & 1 deletion services/pagure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MyPagure(Generic):
Pagure
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url, token=creds.get("token"))
self.issue_api_url = f"{self.url}/api/0/{{repo}}/issue/{{issue}}"
self.issue_web_url = f"{self.url}/{{repo}}/issue/{{issue}}"
Expand Down
4 changes: 2 additions & 2 deletions services/redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MyRedmine(Service):
Redmine
"""

def __init__(self, url: str, creds: dict):
def __init__(self, url: str, creds: dict) -> None:
super().__init__(url)
options = {
"raise_attr_exception": False,
Expand All @@ -31,7 +31,7 @@ def __init__(self, url: str, creds: dict):
if os.getenv("DEBUG"):
self.client.engine.session.hooks["response"].append(debugme)

def close(self):
def close(self) -> None:
try:
self.client.engine.session.close()
except AttributeError:
Expand Down

0 comments on commit 4449b32

Please sign in to comment.