artresizer: add some missing typings

This commit is contained in:
Serene-Arc 2023-01-22 12:12:44 +10:00 committed by wisp3rwind
parent 996a116a62
commit 7acfe8932a

View file

@ -58,7 +58,7 @@ _NOT_AVAILABLE = object()
class LocalBackend: class LocalBackend:
@classmethod @classmethod
def available(cls): def available(cls) -> bool:
try: try:
cls.version() cls.version()
return True return True
@ -76,7 +76,7 @@ class IMBackend(LocalBackend):
_legacy = None _legacy = None
@classmethod @classmethod
def version(cls): def version(cls) -> Optional[Union[object, Tuple[int, int, int]]]:
"""Obtain and cache ImageMagick version. """Obtain and cache ImageMagick version.
Raises `LocalBackendNotAvailableError` if not available. Raises `LocalBackendNotAvailableError` if not available.
@ -206,7 +206,11 @@ class IMBackend(LocalBackend):
log.warning("Could not understand IM output: {0!r}", out) log.warning("Could not understand IM output: {0!r}", out)
return None return None
def deinterlace(self, path_in: AnyStr, path_out: Optional[AnyStr] = None) -> AnyStr: def deinterlace(
self,
path_in: AnyStr,
path_out: Optional[AnyStr] = None,
) -> AnyStr:
if not path_out: if not path_out:
path_out = get_temp_filename(__name__, "deinterlace_IM_", path_in) path_out = get_temp_filename(__name__, "deinterlace_IM_", path_in)
@ -603,7 +607,7 @@ class ArtResizer(metaclass=Shareable):
path_out: Optional[AnyStr]=None, path_out: Optional[AnyStr]=None,
quality: int = 0, quality: int = 0,
max_filesize: int = 0, max_filesize: int = 0,
): ) -> AnyStr:
"""Manipulate an image file according to the method, returning a """Manipulate an image file according to the method, returning a
new path. For PIL or IMAGEMAGIC methods, resizes the image to a new path. For PIL or IMAGEMAGIC methods, resizes the image to a
temporary file and encodes with the specified quality level. temporary file and encodes with the specified quality level.
@ -636,7 +640,7 @@ class ArtResizer(metaclass=Shareable):
# FIXME: Should probably issue a warning? # FIXME: Should probably issue a warning?
return path_in return path_in
def proxy_url(self, maxwidth: int, url: str, quality: int = 0): def proxy_url(self, maxwidth: int, url: str, quality: int = 0) -> str:
"""Modifies an image URL according the method, returning a new """Modifies an image URL according the method, returning a new
URL. For WEBPROXY, a URL on the proxy server is returned. URL. For WEBPROXY, a URL on the proxy server is returned.
Otherwise, the URL is returned unmodified. Otherwise, the URL is returned unmodified.