diff --git a/fftcg/book.py b/fftcg/book.py index 1962e2c..277266b 100644 --- a/fftcg/book.py +++ b/fftcg/book.py @@ -2,6 +2,7 @@ import logging from PIL import Image +from .cards import Cards from .imageloader import ImageLoader @@ -21,7 +22,7 @@ class Book: # Card back image by Aurik __BACK_URL = "http://cloud-3.steamusercontent.com/ugc/948455238665576576/85063172B8C340602E8D6C783A457122F53F7843/" - def __init__(self, cards, grid, resolution, language, num_threads): + def __init__(self, cards: Cards, grid: tuple, resolution: tuple, language: str, num_threads: int): logger = logging.getLogger(__name__) # sort cards by element, then alphabetically @@ -46,7 +47,7 @@ class Book: # width, height per card w, h = resolution - def paste_image(page, index, image): + def paste_image(page: Image, index: int, image: Image): x, y = (index % c) * w, (index // c) * h page.paste(image, (x, y)) @@ -65,6 +66,6 @@ class Book: self.__pages.append(page) - def save(self, filename): + def save(self, filename: str): for i, page in enumerate(self.__pages): page.save(filename.format(i)) diff --git a/fftcg/card.py b/fftcg/card.py index e4feb0e..13b8501 100644 --- a/fftcg/card.py +++ b/fftcg/card.py @@ -13,7 +13,7 @@ class Card: '闇': "Darkness" } - def __init__(self, data, language="EN"): + def __init__(self, data: dict, language: str = "EN"): if not data: self.__opus = "0" self.__serial = "000" diff --git a/fftcg/imageloader.py b/fftcg/imageloader.py index e556fb7..ca5ea5b 100644 --- a/fftcg/imageloader.py +++ b/fftcg/imageloader.py @@ -8,7 +8,7 @@ from PIL import Image class ImageLoader(threading.Thread): - def __init__(self, url_queue, resolution, language): + def __init__(self, url_queue: queue.Queue, resolution: tuple, language: str): threading.Thread.__init__(self) self.__queue = url_queue @@ -44,7 +44,7 @@ class ImageLoader(threading.Thread): self.__queue.task_done() @classmethod - def load(cls, urls, resolution, language, num_threads): + def load(cls, urls: list, resolution: tuple, language: str, num_threads: int): url_queue = queue.Queue() for url in urls: url_queue.put(url) diff --git a/fftcg/opus.py b/fftcg/opus.py index 4802ac2..a965621 100644 --- a/fftcg/opus.py +++ b/fftcg/opus.py @@ -6,13 +6,13 @@ from .cards import Cards class Opus(Cards): - def __init__(self, opus_id): + def __init__(self, opus_id: str): logger = logging.getLogger(__name__) - if isinstance(opus_id, str) and opus_id.isnumeric(): + if opus_id.isnumeric(): roman_opus_id = roman.toRoman(int(opus_id)) params_add = {"set": [f"Opus {roman_opus_id.upper()}"]} - self.__number = str(opus_id) + self.__number = opus_id self.__name = f"opus_{opus_id}" elif opus_id == "chaos":