fixed few mypy related issues.

This commit is contained in:
Cédric Bonhomme 2023-04-26 14:17:49 +02:00
parent 6d87ba2921
commit 7abce7d5d9
No known key found for this signature in database
GPG key ID: A1CB94DE57B7A70D

View file

@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Stegano - Stegano is a pure Python steganography module.
# Copyright (C) 2010-2022 Cédric Bonhomme - https://www.cedricbonhomme.org
#
@ -28,7 +26,7 @@ __license__ = "GPLv3"
import base64
import itertools
from functools import reduce
from typing import IO, Iterator, List, Tuple, Union
from typing import IO, List, Tuple, Union
from PIL import Image
@ -78,7 +76,7 @@ def setlsb(component: int, bit: str) -> int:
def n_at_a_time(
items: List[int], n: int, fillvalue: str
) -> Iterator[Tuple[Union[int, str]]]:
) -> itertools.zip_longest[Tuple[object, ...]]:
"""Returns an iterator which groups n items at a time.
Any final partial tuple will be padded with the fillvalue
@ -134,7 +132,7 @@ class Hider:
if image.mode not in ["RGB", "RGBA"]:
if not auto_convert_rgb:
print("The mode of the image is not RGB. Mode is {}".format(image.mode))
print(f"The mode of the image is not RGB. Mode is {image.mode}")
answer = input("Convert the image to RGB ? [Y / n]\n") or "Y"
if answer.lower() == "n":
raise Exception("Not a RGB image.")
@ -154,7 +152,7 @@ class Hider:
if self._len_message_bits > npixels * 3:
raise Exception(
"The message you want to hide is too long: {}".format(message_length)
f"The message you want to hide is too long: {message_length}"
)
def encode_another_pixel(self):