diff --git a/vsexprtools/exprop.py b/vsexprtools/exprop.py index 556584f..8d448a1 100644 --- a/vsexprtools/exprop.py +++ b/vsexprtools/exprop.py @@ -1,11 +1,10 @@ from __future__ import annotations -from enum import Enum from itertools import cycle from math import isqrt -from typing import Any, Iterable, Iterator, List, SupportsFloat +from typing import Any, Iterable, Iterator, SupportsFloat -from vstools import ConvMode, StrList, flatten +from vstools import ConvMode, CustomStrEnum, StrList, flatten from .util import aka_expr_available @@ -14,7 +13,7 @@ ] -class ExprOp(str, Enum): +class ExprOp(CustomStrEnum): # 1 Argument EXP = "exp" LOG = "log" @@ -78,7 +77,7 @@ def __next__(self) -> ExprOp: def __iter__(self) -> Iterator[ExprOp]: return cycle([self]) - def __mul__(self, n: int) -> List[ExprOp]: # type: ignore[override] + def __mul__(self, n: int) -> list[ExprOp]: # type: ignore[override] return [self] * n @classmethod diff --git a/vsexprtools/funcs.py b/vsexprtools/funcs.py index d20b0db..cfe7285 100644 --- a/vsexprtools/funcs.py +++ b/vsexprtools/funcs.py @@ -1,13 +1,14 @@ from __future__ import annotations from math import ceil -from typing import Any, Iterable, List, Literal, Sequence, Tuple +from typing import Any, Iterable, Literal, Sequence - -from vstools import PlanesT, StrArr, StrArrOpt, StrList, SupportsString, VideoFormatT, get_video_format, to_arr +from vstools import ( + EXPR_VARS, PlanesT, StrArr, StrArrOpt, StrList, SupportsString, VideoFormatT, core, get_video_format, to_arr, vs +) from .exprop import ExprOp -from .util import EXPR_VARS, aka_expr_available, norm_expr_planes +from .util import aka_expr_available, norm_expr_planes __all__ = [ 'expr_func', 'combine', 'norm_expr' @@ -47,7 +48,7 @@ def expr_func( ) from e -def _combine_norm__ix(ffix: StrArrOpt, n_clips: int) -> List[SupportsString]: +def _combine_norm__ix(ffix: StrArrOpt, n_clips: int) -> list[SupportsString]: if ffix is None: return [''] * n_clips @@ -74,7 +75,7 @@ def combine( def norm_expr( - clips: vs.VideoNode | Iterable[vs.VideoNode], expr: str | StrArr | Tuple[str | StrArr, ...], + clips: vs.VideoNode | Iterable[vs.VideoNode], expr: str | StrArr | tuple[str | StrArr, ...], planes: PlanesT = None, format: VideoFormatT | None = None, opt: bool | None = None, boundary: bool = False, force_akarin: Literal[False] | str = False, **kwargs: Any ) -> vs.VideoNode: diff --git a/vsexprtools/manager.py b/vsexprtools/manager.py index 9e8678d..f260376 100644 --- a/vsexprtools/manager.py +++ b/vsexprtools/manager.py @@ -3,13 +3,13 @@ import builtins from contextlib import AbstractContextManager from types import TracebackType -from typing import List, NamedTuple, Sequence, Type +from typing import NamedTuple, Sequence +from vstools import EXPR_VARS, vs from .funcs import expr_func from .operators import ExprOperators from .polyfills import global_builtins, global_builtins_expr -from .util import EXPR_VARS from .variables import ClipVar, ComputedVar, ExprVar __all__ = [ @@ -18,13 +18,13 @@ class InlineExpr(NamedTuple): - clips: List[ClipVar] + clips: list[ClipVar] op: ExprOperators out: inline_expr class inline_expr(AbstractContextManager[InlineExpr]): - _clips: List[vs.VideoNode] + _clips: list[vs.VideoNode] _in_context: bool _final_clip: vs.VideoNode | None _final_expr_node: ComputedVar @@ -48,7 +48,7 @@ def __enter__(self) -> InlineExpr: return InlineExpr(self._clips_char_map, ExprOperators(), self) def __exit__( - self, __exc_type: Type[BaseException] | None, + self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool | None: diff --git a/vsexprtools/operators.py b/vsexprtools/operators.py index ba7ad77..45ab189 100644 --- a/vsexprtools/operators.py +++ b/vsexprtools/operators.py @@ -4,8 +4,8 @@ import operator as op from dataclasses import dataclass from typing import ( - TYPE_CHECKING, Any, Callable, Generic, Iterable, List, Sequence, SupportsAbs, SupportsIndex, SupportsRound, - TypeAlias, Union, cast, overload + TYPE_CHECKING, Any, Callable, Generic, Iterable, Sequence, SupportsAbs, SupportsIndex, SupportsRound, TypeAlias, + Union, cast, overload ) from vstools import R, SupportsFloatOrIndex, SupportsRichComparison, SupportsTrunc, T @@ -228,12 +228,12 @@ def as_var(cls, arg0: ExprOtherT) -> ComputedVar: @overload @classmethod - def as_var(cls, arg0: Sequence[ExprOtherT]) -> List[ComputedVar]: + def as_var(cls, arg0: Sequence[ExprOtherT]) -> list[ComputedVar]: pass @classmethod - def as_var(cls, arg0: ExprOtherT | Sequence[ExprOtherT]) -> ComputedVar | List[ComputedVar]: + def as_var(cls, arg0: ExprOtherT | Sequence[ExprOtherT]) -> ComputedVar | list[ComputedVar]: from .variables import ComputedVar if isinstance(arg0, Sequence): - return cast(List[ComputedVar], list(arg0)) + return cast(list[ComputedVar], list(arg0)) return cast(ComputedVar, arg0) diff --git a/vsexprtools/variables.py b/vsexprtools/variables.py index a0f0134..3d29e84 100644 --- a/vsexprtools/variables.py +++ b/vsexprtools/variables.py @@ -3,13 +3,12 @@ from dataclasses import dataclass from functools import wraps from typing import ( - TYPE_CHECKING, Any, Callable, Iterable, Iterator, Literal, NoReturn, SupportsIndex, Tuple, TypeAlias, cast, overload + TYPE_CHECKING, Any, Callable, Iterable, Iterator, Literal, NoReturn, SupportsIndex, TypeAlias, cast, overload ) - from vstools import ( ByteData, ColorRange, ColorRangeT, F, Self, get_depth, get_lowest_value, get_neutral_value, get_peak_value, - get_plane_sizes, scale_value + get_plane_sizes, scale_value, vs ) from .operators import BaseOperator, ExprOperators @@ -290,7 +289,7 @@ def __str__(self) -> str: # Pixel Access _IdxType: TypeAlias = int | ExprVar - def __getitem__(self, index: _IdxType | Tuple[_IdxType, _IdxType] | slice) -> ComputedVar: # type: ignore + def __getitem__(self, index: _IdxType | tuple[_IdxType, _IdxType] | slice) -> ComputedVar: # type: ignore if isinstance(index, tuple): x, y = index if isinstance(x, ExprVar) or isinstance(y, ExprVar):