Skip to content

Commit

Permalink
Simplify GrainPP.Resolver (#102)
Browse files Browse the repository at this point in the history
griffe (the docs parser used in jet-docs) trips up on the loop of
`GrainPP` -> `GrainPP.Resolver` -> `GrainPP` -> `GrainPP.Resolver` -> etc.
Because of this the whole `vsdeband.noise` module had to be excluded.
While this could be fixed in griffe, it also looked like this could be
both fixed and simplified by just quoting the type (like `'GrainPP'`).
This way there's no loop and no need for `_gpp`.

Also don't need the the explicit `type` in `GrainPostProcessT` (8550361)
anymore.

Verified that the computed type is the same before and after:

    (type) Resolver = (VideoNode) -> GrainPP
  • Loading branch information
sgt0 authored Oct 21, 2024
1 parent dd5ca5a commit ad4a13a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions vsdeband/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from functools import reduce
from typing import TYPE_CHECKING, Any, Callable, Iterable, Protocol, TypeAlias, cast
from typing import Any, Callable, Iterable, Protocol, cast

from vsdenoise import Prefilter
from vsexprtools import complexpr_available, norm_expr
Expand Down Expand Up @@ -33,14 +33,6 @@
]


class _gpp:
if TYPE_CHECKING:
from .noise import GrainPP
Resolver: TypeAlias = Callable[[vs.VideoNode], GrainPP]
else:
Resolver: TypeAlias = Callable[[vs.VideoNode], Any]


class ResolverOneClipArgs(Protocol):
def __call__(self, grained: vs.VideoNode) -> vs.VideoNode:
...
Expand All @@ -52,7 +44,9 @@ def __call__(self, grained: vs.VideoNode, clip: vs.VideoNode) -> vs.VideoNode:


@dataclass
class GrainPP(_gpp):
class GrainPP:
Resolver = Callable[[vs.VideoNode], 'GrainPP']

value: str
kwargs: KwargsT = field(default_factory=lambda: KwargsT())

Expand All @@ -75,7 +69,7 @@ def _resolve(grained: vs.VideoNode) -> vs.VideoNode:


FadeLimits = tuple[int | Iterable[int] | None, int | Iterable[int] | None]
GrainPostProcessT = type[ResolverOneClipArgs | ResolverTwoClipsArgs | str | GrainPP | GrainPP.Resolver]
GrainPostProcessT = ResolverOneClipArgs | ResolverTwoClipsArgs | str | GrainPP | GrainPP.Resolver
GrainPostProcessesT = GrainPostProcessT | list[GrainPostProcessT]


Expand Down

0 comments on commit ad4a13a

Please sign in to comment.