diff --git a/cache.py b/cache.py index e87b1c0..d4008f0 100644 --- a/cache.py +++ b/cache.py @@ -85,7 +85,9 @@ class ImageCache: return datetime.now(timezone.utc) + self.LIFETIME def _hash(self, image: Image) -> ImageHash: - pixel_data = list(image.resize((10, 10), Image_module.LANCZOS).convert('L').getdata()) + pixel_data = list( + image.resize((10, 10), Image_module.Resampling.LANCZOS).convert('L').getdata() + ) avg_pixel = sum(pixel_data) / len(pixel_data) bits = ''.join('1' if px >= avg_pixel else '0' for px in pixel_data) return ImageHash(f"{int(bits, 2):x}.png") @@ -122,6 +124,6 @@ class ImageCache: if photo_key in self._photos: return self._photos[photo_key] if image.size != size: - image = image.resize(size, Image_module.ADAPTIVE) + image = image.resize(size, Image_module.Palette.ADAPTIVE) self._photos[photo_key] = photo = PhotoImage(master=self._root, image=image) return photo diff --git a/gui.py b/gui.py index 599f7b2..b453a7d 100644 --- a/gui.py +++ b/gui.py @@ -159,7 +159,7 @@ class PlaceholderEntry(ttk.Entry): return '' return super().get() - def insert(self, index: tk._EntryIndex, content: str) -> None: + def insert(self, index: str | int, content: str) -> None: # when inserting into the entry externally, disable the placeholder flag if not content: # if an empty string was passed in @@ -167,7 +167,7 @@ class PlaceholderEntry(ttk.Entry): self._remove_placeholder() super().insert(index, content) - def delete(self, first: tk._EntryIndex, last: tk._EntryIndex | None = None) -> None: + def delete(self, first: str | int, last: str | int | None = None) -> None: super().delete(first, last) self._insert_placeholder() @@ -247,9 +247,9 @@ class PaddedListbox(tk.Listbox): pady1 = pady2 = padding[1] elif len(padding) == 3: padx1, padx2 = padding[0], padding[1] - pady1 = pady2 = padding[2] # type: ignore + pady1 = pady2 = padding[2] else: - padx1, padx2, pady1, pady2 = padding # type: ignore + padx1, padx2, pady1, pady2 = padding super().grid(column=0, row=0, padx=(padx1, padx2), pady=(pady1, pady2), sticky="nsew") else: super().grid(column=0, row=0, sticky="nsew") @@ -1043,7 +1043,7 @@ class TrayIcon: def __init__(self, manager: GUIManager, master: ttk.Widget): self._manager = manager - self.icon: pystray.Icon | None = None # type: ignore + self.icon: pystray.Icon | None = None # type: ignore[unused-ignore] self._icon_images: dict[str, Image_module.Image] = { "pickaxe": Image_module.open(resource_path("icons/pickaxe.ico")), "active": Image_module.open(resource_path("icons/active.ico")), @@ -1410,7 +1410,9 @@ class InventoryOverview: ).grid(column=1, row=4, sticky="nw", padx=4) # Image campaign_image = await self._cache.get(campaign.image_url, size=(108, 144)) - ttk.Label(campaign_frame, image=campaign_image).grid(column=0, row=1, rowspan=4) + ttk.Label( + campaign_frame, image=campaign_image # type: ignore[arg-type] + ).grid(column=0, row=1, rowspan=4) # Drops separator ttk.Separator( campaign_frame, orient="vertical", takefocus=False @@ -1429,7 +1431,10 @@ class InventoryOverview: ) for i, benefit, image in zip(range(len(drop.benefits)), drop.benefits, benefit_images): ttk.Label( - benefits_frame, text=benefit.name, image=image, compound="bottom" + benefits_frame, + text=benefit.name, + image=image, # type: ignore[arg-type] + compound="bottom", ).grid(column=i, row=0, padx=5) self._drops[drop.id] = label = MouseOverLabel(drop_frame) self.update_progress(drop, label) diff --git a/utils.py b/utils.py index 257674e..90ef771 100644 --- a/utils.py +++ b/utils.py @@ -40,7 +40,7 @@ logger = logging.getLogger("TwitchDrops") def set_root_icon(root: tk.Tk, image_path: Path | str) -> None: with Image_module.open(image_path) as image: icon_photo = PhotoImage(master=root, image=image) - root.iconphoto(True, icon_photo) + root.iconphoto(True, icon_photo) # type: ignore[arg-type] # keep a reference to the PhotoImage to avoid the ResourceWarning root._icon_image = icon_photo # type: ignore[attr-defined]