From 403da558a54f25bee249a824da0cf63ef1a92824 Mon Sep 17 00:00:00 2001 From: Setsugennoao Date: Thu, 16 May 2024 12:36:49 +0200 Subject: [PATCH] Fix typing --- vskernels/kernels/abstract.py | 13 +++++++------ vskernels/kernels/complex.py | 8 ++++---- vskernels/kernels/docs.py | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/vskernels/kernels/abstract.py b/vskernels/kernels/abstract.py index 9b55204..35ad063 100644 --- a/vskernels/kernels/abstract.py +++ b/vskernels/kernels/abstract.py @@ -100,14 +100,14 @@ def _base_from_param( def _base_ensure_obj( - cls: type[T], - basecls: type[T], - value: str | type[T] | T | None, + cls: type[BaseScalerT], + basecls: type[BaseScalerT], + value: str | type[BaseScalerT] | BaseScalerT | None, exception_cls: type[CustomValueError], excluded: Sequence[type] = [], func_except: FuncExceptT | None = None -) -> T: - new_scaler: T +) -> BaseScalerT: + new_scaler: BaseScalerT if value is None: new_scaler = cls() @@ -277,7 +277,8 @@ class Descaler(BaseScaler): @inject_self.cached @inject_kwargs_params def descale( # type: ignore[override] - self, clip: vs.VideoNode, width: int | None, height: int | None, shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any + self, clip: vs.VideoNode, width: int | None, height: int | None, + shift: tuple[TopShift, LeftShift] = (0, 0), **kwargs: Any ) -> vs.VideoNode: width, height = self._wh_norm(clip, width, height) diff --git a/vskernels/kernels/complex.py b/vskernels/kernels/complex.py index 44f297a..f4e29ec 100644 --- a/vskernels/kernels/complex.py +++ b/vskernels/kernels/complex.py @@ -111,7 +111,7 @@ class LinearScaler(_BaseLinearOperation, Scaler): @inject_self.cached @inject_kwargs_params def scale( # type: ignore[override] - self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, + self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, shift: tuple[TopShift, LeftShift] = (0, 0), *, linear: bool = False, sigmoid: bool | tuple[Slope, Center] = False, **kwargs: Any ) -> vs.VideoNode: @@ -156,7 +156,7 @@ def _get_kwargs_keep_ar( return kwargs def _handle_crop_resize_kwargs( # type: ignore[override] - self, clip: vs.VideoNode, width: int | None, height: int | None, shift: tuple[TopShift, LeftShift], + self, clip: vs.VideoNode, width: int, height: int, shift: tuple[TopShift, LeftShift], sar: Sar | bool | float | None, dar: Dar | bool | float | None, **kwargs: Any ) -> tuple[KwargsT, tuple[TopShift, LeftShift], Sar | None]: kwargs.setdefault('src_top', kwargs.pop('sy', shift[0])) @@ -202,7 +202,7 @@ def _handle_crop_resize_kwargs( # type: ignore[override] @inject_self.cached @inject_kwargs_params def scale( # type: ignore[override] - self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, + self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, shift: tuple[TopShift, LeftShift] = (0, 0), *, border_handling: BorderHandling = BorderHandling.MIRROR, sar: Sar | float | bool | None = None, dar: Dar | float | bool | None = None, keep_ar: bool = False, @@ -237,7 +237,7 @@ class ComplexScaler(LinearScaler, KeepArScaler): @inject_self.cached @inject_kwargs_params def scale( # type: ignore[override] - self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, + self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, shift: tuple[TopShift, LeftShift] = (0, 0), *, border_handling: BorderHandling = BorderHandling.MIRROR, diff --git a/vskernels/kernels/docs.py b/vskernels/kernels/docs.py index a6010dc..3aa0a5f 100644 --- a/vskernels/kernels/docs.py +++ b/vskernels/kernels/docs.py @@ -43,7 +43,8 @@ def scale( # type: ignore[override] @inject_self.cached def descale( # type: ignore[override] - self, clip: vs.VideoNode, width: int | None, height: int | None, shift: tuple[float, float] = (0, 0), **kwargs: Any + self, clip: vs.VideoNode, width: int | None, height: int | None, + shift: tuple[float, float] = (0, 0), **kwargs: Any ) -> vs.VideoNode: """ Perform a regular descaling operation.