From 6eda21c249484c21d83e838bcca507fedcd39a13 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 27 Sep 2020 13:56:54 -0400 Subject: [PATCH] More strict mypy checking --- mypy.ini | 1 + win2xcur/cursor.py | 4 ++-- win2xcur/main.py | 3 ++- win2xcur/parser/ani.py | 3 +++ win2xcur/shadow.py | 6 ++++-- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index 976ba02..5a12ab1 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,3 @@ [mypy] ignore_missing_imports = True +strict = true diff --git a/win2xcur/cursor.py b/win2xcur/cursor.py index 49e9087..903e8f0 100644 --- a/win2xcur/cursor.py +++ b/win2xcur/cursor.py @@ -13,11 +13,11 @@ class CursorImage: class CursorFrame: - def __init__(self, images: List[CursorImage], delay=0) -> None: + def __init__(self, images: List[CursorImage], delay: int = 0) -> None: self.images = images self.delay = delay - def __getitem__(self, item) -> CursorImage: + def __getitem__(self, item: int) -> CursorImage: return self.images[item] def __len__(self) -> int: diff --git a/win2xcur/main.py b/win2xcur/main.py index e09582a..b13958b 100644 --- a/win2xcur/main.py +++ b/win2xcur/main.py @@ -5,6 +5,7 @@ import traceback from multiprocessing import cpu_count from multiprocessing.pool import ThreadPool from threading import Lock +from typing import BinaryIO from win2xcur import shadow from win2xcur.parser import open_blob @@ -37,7 +38,7 @@ def main() -> None: check_xcursorgen() - def process(file) -> None: + def process(file: BinaryIO) -> None: name = file.name blob = file.read() try: diff --git a/win2xcur/parser/ani.py b/win2xcur/parser/ani.py index ba1a08f..e7aa2f4 100644 --- a/win2xcur/parser/ani.py +++ b/win2xcur/parser/ani.py @@ -20,6 +20,9 @@ class ANIParser(BaseParser): @classmethod def can_parse(cls, blob: bytes) -> bool: + signature: bytes + size: int + subtype: bytes signature, size, subtype = cls.RIFF_HEADER.unpack(blob[:cls.RIFF_HEADER.size]) return signature == cls.SIGNATURE and size == len(blob) - 8 and subtype == cls.ANI_TYPE diff --git a/win2xcur/shadow.py b/win2xcur/shadow.py index 0e97661..11b991b 100644 --- a/win2xcur/shadow.py +++ b/win2xcur/shadow.py @@ -22,7 +22,9 @@ def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float, return result -def apply_to_frames(frames: List[CursorFrame], **kwargs) -> None: +def apply_to_frames(frames: List[CursorFrame], *, color: str, radius: float, + sigma: float, xoffset: float, yoffset: float) -> None: for frame in frames: for cursor in frame: - cursor.image = apply_to_image(cursor.image, **kwargs) + cursor.image = apply_to_image(cursor.image, color=color, radius=radius, + sigma=sigma, xoffset=xoffset, yoffset=yoffset)