Skip to content

Commit

Permalink
Update tifffile/numcodecs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke committed Sep 19, 2024
1 parent e3d22fd commit f45049c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tifffile/numcodecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
__all__ = ['register_codec', 'Tiff']

from io import BytesIO
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

from numcodecs import registry
from numcodecs.abc import Codec
Expand All @@ -45,6 +45,7 @@

if TYPE_CHECKING:
from collections.abc import Iterable, Sequence
from typing import Any

from .tifffile import (
COMPRESSION,
Expand All @@ -57,7 +58,7 @@
)


class Tiff(Codec):
class Tiff(Codec): # type: ignore[misc]
"""TIFF codec for Numcodecs."""

codec_id = 'tifffile'
Expand Down Expand Up @@ -88,7 +89,7 @@ def __init__(
extratags: Sequence[TagTuple] | None = None,
truncate: bool = False,
maxworkers: int | None = None,
):
) -> None:
self.key = key
self.series = series
self.level = level
Expand All @@ -111,7 +112,7 @@ def __init__(
self.truncate = truncate
self.maxworkers = maxworkers

def encode(self, buf):
def encode(self, buf: Any) -> bytes:
"""Return TIFF file as bytes."""
with BytesIO() as fh:
with TiffWriter(
Expand Down Expand Up @@ -141,7 +142,7 @@ def encode(self, buf):
result = fh.getvalue()
return result

def decode(self, buf, out=None):
def decode(self, buf: Any, out: Any = None) -> Any:
"""Return decoded image as NumPy array."""
with BytesIO(buf) as fh:
with TiffFile(fh) as tif:
Expand Down

0 comments on commit f45049c

Please sign in to comment.