From a0134b6aa97a2923537b410da980a694559ac3c5 Mon Sep 17 00:00:00 2001 From: scaramallion Date: Mon, 17 Jun 2024 13:01:15 +1000 Subject: [PATCH 1/2] Minor typing fixes --- pylibjpeg/utils.py | 7 +++++-- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pylibjpeg/utils.py b/pylibjpeg/utils.py index 747e670..da921ca 100644 --- a/pylibjpeg/utils.py +++ b/pylibjpeg/utils.py @@ -32,7 +32,7 @@ def __call__(self, src: bytes, **kwargs: Any) -> np.ndarray: class Encoder(Protocol): - def __call__(self, src: np.ndarray, **kwargs: Any) -> Union[bytes, bytearray]: + def __call__(self, src: np.ndarray | bytes, **kwargs: Any) -> Union[bytes, bytearray]: ... # pragma: no cover @@ -347,7 +347,10 @@ def get_pixel_data_decoders( entry_point = "pylibjpeg.pixel_data_decoders" decoders = cast( - Union[Dict[str, Decoder], Dict[str, Dict[str, Decoder]]], + Union[ + Dict[str, Union[Decoder, Encoder]], + Dict[str, Dict[str, Union[Decoder, Encoder]]], + ], _get_pixel_data_plugins(entry_point, version), ) return decoders diff --git a/pyproject.toml b/pyproject.toml index 086ee89..91faa5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ license = {text = "MIT"} name = "pylibjpeg" readme = "README.md" requires-python = ">=3.8" -version = "2.0.0" +version = "2.0.1" [project.optional-dependencies] From f20f62c33d6faafe5cc9dc5c05a1af2ed0b2ffc2 Mon Sep 17 00:00:00 2001 From: scaramallion Date: Mon, 17 Jun 2024 13:03:52 +1000 Subject: [PATCH 2/2] Fix type spec --- pylibjpeg/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylibjpeg/utils.py b/pylibjpeg/utils.py index da921ca..642e945 100644 --- a/pylibjpeg/utils.py +++ b/pylibjpeg/utils.py @@ -32,7 +32,7 @@ def __call__(self, src: bytes, **kwargs: Any) -> np.ndarray: class Encoder(Protocol): - def __call__(self, src: np.ndarray | bytes, **kwargs: Any) -> Union[bytes, bytearray]: + def __call__(self, src: Union[np.ndarray, bytes], **kwargs: Any) -> Union[bytes, bytearray]: ... # pragma: no cover