Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion av/audio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from .frame import AudioFrame as AudioFrame
from .stream import AudioStream as AudioStream

# FFmpeg 9.0 encoders and the codec descriptor aliases that resolve to them.
_AudioCodecName = Literal[
type _AudioCodecName = Literal[
"aac",
"aac_at",
"aac_mf",
Expand Down
2 changes: 1 addition & 1 deletion av/audio/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from .layout import AudioLayout
from .plane import AudioPlane

format_dtypes: dict[str, str]
_SupportedNDarray = (
type _SupportedNDarray = (
npt.NDArray[np.float64]
| npt.NDArray[np.float32]
| npt.NDArray[np.int32]
Expand Down
11 changes: 4 additions & 7 deletions av/packet.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Buffer as _BufferLike
from collections.abc import Iterator
from fractions import Fraction
from typing import Generic, Literal, TypeVar, final, overload
from typing import Literal, final, overload

from av.audio.frame import AudioFrame
from av.audio.stream import AudioStream
Expand Down Expand Up @@ -80,15 +80,12 @@ class PacketSideData(Buffer):
def packet_sidedata_type_to_literal(dtype: int) -> PktSideDataT: ...
def packet_sidedata_type_from_literal(dtype: PktSideDataT) -> int: ...

# TypeVar for stream types - bound to Stream so it can be any stream type
_StreamT = TypeVar("_StreamT", bound=Stream)

@final
class Packet(Buffer, Generic[_StreamT]):
class Packet[StreamT: Stream](Buffer):
@property
def stream(self) -> _StreamT | None: ...
def stream(self) -> StreamT | None: ...
@stream.setter
def stream(self, value: _StreamT) -> None: ...
def stream(self, value: StreamT) -> None: ...
stream_index: int
@property
def time_base(self) -> AVRational: ...
Expand Down
2 changes: 1 addition & 1 deletion av/rational.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from fractions import Fraction
from numbers import Rational
from typing import final, overload

_Comparable = AVRational | Rational | Decimal | float
type _Comparable = AVRational | Rational | Decimal | float

@final
class AVRational:
Expand Down
14 changes: 6 additions & 8 deletions av/sidedata/sidedata.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Iterator, Mapping, Sequence
from enum import Enum
from typing import Literal, Self, TypeVar, overload
from typing import Literal, Self, overload

from typing_extensions import disjoint_base

Expand All @@ -10,8 +10,6 @@ from av.frame import Frame
from .encparams import VideoEncParams
from .motionvectors import MotionVectors

_T = TypeVar("_T")

class Type(Enum):
_value_: int
PANSCAN = ...
Expand Down Expand Up @@ -47,8 +45,8 @@ class Type(Enum):
THREE_D_REFERENCE_DISPLAYS = ...
EXIF = ...

_MotionVectorsKey = Literal["MOTION_VECTORS", Type.MOTION_VECTORS]
_VideoEncParamsKey = Literal["VIDEO_ENC_PARAMS", Type.VIDEO_ENC_PARAMS]
type _MotionVectorsKey = Literal["MOTION_VECTORS", Type.MOTION_VECTORS]
type _VideoEncParamsKey = Literal["VIDEO_ENC_PARAMS", Type.VIDEO_ENC_PARAMS]

@disjoint_base
class SideData(Buffer):
Expand All @@ -69,6 +67,6 @@ class SideDataContainer(Mapping[Type, SideData]):
@overload
def get(self, key: str | int | Type, /) -> SideData | None: ...
@overload
def get(
self, key: str | int | Type, default: SideData | _T, /
) -> SideData | _T: ...
def get[T](
self, key: str | int | Type, default: SideData | T, /
) -> SideData | T: ...
2 changes: 1 addition & 1 deletion av/subtitles/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Literal

# FFmpeg 9.0 encoders and the codec descriptor aliases that resolve to them.
_SubtitleCodecName = Literal[
type _SubtitleCodecName = Literal[
"ass",
"dvb_subtitle",
"dvbsub",
Expand Down
2 changes: 1 addition & 1 deletion av/video/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from .frame import VideoFrame as VideoFrame
from .stream import VideoStream as VideoStream

# FFmpeg 9.0 encoders and the codec descriptor aliases that resolve to them.
_VideoCodecName = Literal[
type _VideoCodecName = Literal[
"a64_multi",
"a64_multi5",
"a64multi",
Expand Down
4 changes: 1 addition & 3 deletions av/video/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from .format import VideoFormat
from .plane import VideoPlane
from .reformatter import ColorPrimaries, ColorTrc

_SupportedNDarray = (
type _SupportedNDarray = (
npt.NDArray[np.uint8]
| npt.NDArray[np.uint16]
| npt.NDArray[np.float16]
Expand Down Expand Up @@ -78,8 +78,6 @@ class VideoFrame(Frame):
@property
def sw_format(self) -> VideoFormat | None: ...
@property
def time(self) -> float | None: ...
@property
def width(self) -> int: ...
@property
def height(self) -> int: ...
Expand Down
6 changes: 2 additions & 4 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@

if TYPE_CHECKING:
from collections.abc import Callable
from typing import Any, TypeVar
from typing import Any

from PIL.Image import Image

T = TypeVar("T")


__all__ = ("fate_suite",)

Expand Down Expand Up @@ -84,7 +82,7 @@ def sandboxed(


# Decorator for running a test in the sandbox directory
def run_in_sandbox(func: Callable[..., T]) -> Callable[..., T]:
def run_in_sandbox[T](func: Callable[..., T]) -> Callable[..., T]:
@functools.wraps(func)
def _inner(self: Any, *args: Any, **kwargs: Any) -> T:
current_dir = os.getcwd()
Expand Down
Loading