Skip to content

Commit

Permalink
typingfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Sep 8, 2023
1 parent 620f6a4 commit f96752c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions bugme.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
from concurrent.futures import ThreadPoolExecutor
from urllib.parse import urlparse, parse_qs
from typing import Any, Generator, List, Union
from typing import Any, Dict, Generator, List, Union

from datetime import datetime
from dateutil import parser
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(self, **kwargs):

# Allow access this object as a dictionary

def __getitem__(self, item: str):
def __getitem__(self, item: str) -> Any:
try:
return getattr(self, item)
except AttributeError as exc:
Expand Down Expand Up @@ -101,7 +101,7 @@ class Service:
Service class to abstract methods
"""

def __init__(self, url):
def __init__(self, url: str):
url = url.rstrip("/")
self.url = url if urlparse(url).scheme else f"https://{url}"

Expand Down Expand Up @@ -169,7 +169,7 @@ def get_items(self, items: List[Item]) -> Generator[Union[Item, None], None, Non
except BugzillaError as exc:
logging.error("Bugzilla: %s: get_items(): %s", self.url, exc)

def _to_item(self, info) -> Union[Item, None]:
def _to_item(self, info: Any) -> Union[Item, None]:
return Item(
issue_id=info.id,
status=info.status,
Expand Down Expand Up @@ -201,7 +201,7 @@ def get_item(self, item: Item) -> Union[Item, None]:
return None
return self._to_item(info, item)

def _to_item(self, info, item) -> Union[Item, None]:
def _to_item(self, info: Any, item: Item) -> Union[Item, None]:
return Item(
issue_id=info.number,
status=info.state,
Expand Down Expand Up @@ -242,7 +242,7 @@ def get_item(self, item: Item) -> Union[Item, None]:
return None
return self._to_item(info, item)

def _to_item(self, info, item) -> Union[Item, None]:
def _to_item(self, info: Any, item: Item) -> Union[Item, None]:
return Item(
issue_id=info.iid,
status=info.state,
Expand Down Expand Up @@ -273,7 +273,7 @@ def get_item(self, item: Item) -> Union[Item, None]:
return None
return self._to_item(info)

def _to_item(self, info) -> Union[Item, None]:
def _to_item(self, info: Any) -> Union[Item, None]:
return Item(
issue_id=info.id,
status=info.status,
Expand All @@ -284,7 +284,7 @@ def _to_item(self, info) -> Union[Item, None]:
)


def main():
def main() -> None:
"""
Main function
"""
Expand All @@ -293,15 +293,17 @@ def main():
sys.exit(f"ERROR: {CREDENTIALS_FILE} has insecure permissions")
creds = json.load(file)

items = {}
items: Dict[str, List[Item]] = {}
for arg in sys.argv[1:]:
item = get_item(arg)
if item["host"] not in item:
if item is None:
continue
if item["host"] not in items:
items[item["host"]] = []
else:
items[item["host"]].append(item)

clients = {}
clients: Dict[str, Any] = {}
for host in items:
if host == "bugzilla.suse.com":
clients[host] = MyBugzilla(f"https://{host}", creds[host])
Expand Down

0 comments on commit f96752c

Please sign in to comment.