diff --git a/av/audio/stream.pyi b/av/audio/stream.pyi index e14323f2a..cf4173759 100644 --- a/av/audio/stream.pyi +++ b/av/audio/stream.pyi @@ -12,5 +12,5 @@ class AudioStream(Stream): format: AudioFormat codec_context: AudioCodecContext - def encode(self, frame: AudioFrame | None = None) -> list[Packet]: ... + def encode(self, frame: AudioFrame | None = None) -> list[Packet]: ... # type: ignore[override] def decode(self, packet: Packet | None = None) -> list[AudioFrame]: ... diff --git a/av/format.pyi b/av/format.pyi index 7eb3d1ce5..874920928 100644 --- a/av/format.pyi +++ b/av/format.pyi @@ -1,3 +1,5 @@ +__all__ = ("ContainerFormat", "formats_available") + from .enum import EnumFlag class Flags(EnumFlag): diff --git a/av/sidedata/motionvectors.pyi b/av/sidedata/motionvectors.pyi index 5fe4e733a..eb514eb70 100644 --- a/av/sidedata/motionvectors.pyi +++ b/av/sidedata/motionvectors.pyi @@ -1,11 +1,16 @@ -from typing import Any, Sequence +from typing import Any, Sequence, overload import numpy as np from .sidedata import SideData -class MotionVectors(SideData, Sequence[Any]): - def __getitem__(self, index: int) -> MotionVector: ... +class MotionVectors(SideData, Sequence[MotionVector]): + @overload + def __getitem__(self, index: int): ... + @overload + def __getitem__(self, index: slice): ... + @overload + def __getitem__(self, index: int | slice): ... def __len__(self) -> int: ... def to_ndarray(self) -> np.ndarray[Any, Any]: ... diff --git a/av/sidedata/sidedata.pyi b/av/sidedata/sidedata.pyi index c0d4ba314..ac28f0dee 100644 --- a/av/sidedata/sidedata.pyi +++ b/av/sidedata/sidedata.pyi @@ -1,4 +1,5 @@ from collections.abc import Mapping +from typing import Iterator, Sequence, overload from av.buffer import Buffer from av.enum import EnumItem @@ -27,5 +28,13 @@ class SideData(Buffer): type: Type DISPLAYMATRIX: int -class SideDataContainer(Mapping[str, int]): +class SideDataContainer(Mapping): frame: Frame + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[SideData]: ... + @overload + def __getitem__(self, key: int) -> SideData: ... + @overload + def __getitem__(self, key: slice) -> Sequence[SideData]: ... + @overload + def __getitem__(self, key: int | slice) -> SideData | Sequence[SideData]: ... diff --git a/av/video/stream.pyi b/av/video/stream.pyi index 2ef4adf89..b0266328a 100644 --- a/av/video/stream.pyi +++ b/av/video/stream.pyi @@ -24,5 +24,5 @@ class VideoStream(Stream): thread_count: int thread_type: Any - def encode(self, frame: VideoFrame | None = None) -> list[Packet]: ... + def encode(self, frame: VideoFrame | None = None) -> list[Packet]: ... # type: ignore[override] def decode(self, packet: Packet | None = None) -> list[VideoFrame]: ...