From 8938d6996cfd82a48b913678423f647c0537b952 Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 21 Oct 2026 23:47:36 +0200 Subject: [PATCH] `sidedata.*`: fix stubtest errors --- av/sidedata/encparams.pyi | 9 +++++++-- av/sidedata/motionvectors.pyi | 12 ++++++++++-- av/sidedata/sidedata.pyi | 13 +++++++------ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/av/sidedata/encparams.pyi b/av/sidedata/encparams.pyi index de962ba51..3260bd85e 100644 --- a/av/sidedata/encparams.pyi +++ b/av/sidedata/encparams.pyi @@ -1,15 +1,18 @@ from enum import IntEnum -from typing import Any, cast +from typing import Any, cast, final import numpy as np +from .sidedata import SideData + class VideoEncParamsType(IntEnum): NONE = cast(int, ...) VP9 = cast(int, ...) H264 = cast(int, ...) MPEG2 = cast(int, ...) -class VideoEncParams: +@final +class VideoEncParams(SideData): nb_blocks: int blocks_offset: int block_size: int @@ -19,9 +22,11 @@ class VideoEncParams: def block_params(self, idx: int) -> VideoBlockParams: ... def qp_map(self) -> np.ndarray[Any, Any]: ... +@final class VideoBlockParams: src_x: int src_y: int w: int h: int delta_qp: int + def __init__(self, video_enc_params: VideoEncParams, idx: int, /) -> None: ... diff --git a/av/sidedata/motionvectors.pyi b/av/sidedata/motionvectors.pyi index 80690a4b1..232910213 100644 --- a/av/sidedata/motionvectors.pyi +++ b/av/sidedata/motionvectors.pyi @@ -1,16 +1,21 @@ from collections.abc import Iterator -from typing import Any +from typing import Any, final import numpy as np +from av.frame import Frame + from .sidedata import SideData +@final class MotionVectors(SideData): - def __getitem__(self, index: int) -> MotionVector: ... + def __init__(self, sentinel: object, frame: Frame, index: int, /) -> None: ... + def __getitem__(self, index: int, /) -> MotionVector: ... def __iter__(self) -> Iterator[MotionVector]: ... def __len__(self) -> int: ... def to_ndarray(self) -> np.ndarray[Any, Any]: ... +@final class MotionVector: source: int w: int @@ -22,3 +27,6 @@ class MotionVector: motion_x: int motion_y: int motion_scale: int + def __init__( + self, sentinel: object, parent: MotionVectors, index: int, / + ) -> None: ... diff --git a/av/sidedata/sidedata.pyi b/av/sidedata/sidedata.pyi index 94f500b13..7107085b8 100644 --- a/av/sidedata/sidedata.pyi +++ b/av/sidedata/sidedata.pyi @@ -2,7 +2,10 @@ from collections.abc import Iterator, Mapping, Sequence from enum import Enum from typing import ClassVar, cast, overload +from typing_extensions import disjoint_base + from av.buffer import Buffer +from av.frame import Frame class Type(Enum): PANSCAN = cast(ClassVar[Type], ...) @@ -38,17 +41,15 @@ class Type(Enum): THREE_D_REFERENCE_DISPLAYS = cast(ClassVar[Type], ...) EXIF = cast(ClassVar[Type], ...) +@disjoint_base class SideData(Buffer): type: Type + def __init__(self, sentinel: object, frame: Frame, index: int, /) -> None: ... class SideDataContainer(Mapping): def __len__(self) -> int: ... def __iter__(self) -> Iterator[Type]: ... @overload - def __getitem__(self, key: str | int | Type) -> SideData: ... - @overload - def __getitem__(self, key: slice) -> Sequence[SideData]: ... + def __getitem__(self, key: str | int | Type, /) -> SideData: ... @overload - def __getitem__( - self, key: str | int | Type | slice - ) -> SideData | Sequence[SideData]: ... + def __getitem__(self, key: slice, /) -> Sequence[SideData]: ...