diff --git a/av/audio/fifo.pyi b/av/audio/fifo.pyi index 085ed4bba..31c2aa8dc 100644 --- a/av/audio/fifo.pyi +++ b/av/audio/fifo.pyi @@ -1,7 +1,10 @@ +from typing import final + from .format import AudioFormat from .frame import AudioFrame from .layout import AudioLayout +@final class AudioFifo: def write(self, frame: AudioFrame) -> None: ... def read(self, samples: int = 0, partial: bool = False) -> AudioFrame | None: ... diff --git a/av/audio/format.pyi b/av/audio/format.pyi index 5f7e322ed..ffd68ec4b 100644 --- a/av/audio/format.pyi +++ b/av/audio/format.pyi @@ -1,3 +1,6 @@ +from typing import final + +@final class AudioFormat: name: str bytes: int diff --git a/av/audio/frame.pyi b/av/audio/frame.pyi index 8efb26760..6e49d5641 100644 --- a/av/audio/frame.pyi +++ b/av/audio/frame.pyi @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, final import numpy as np @@ -25,6 +25,7 @@ class _Layout: def __get__(self, i: object | None, owner: type | None = None) -> AudioLayout: ... def __set__(self, instance: object, value: AudioLayout | str) -> None: ... +@final class AudioFrame(Frame): planes: tuple[AudioPlane, ...] samples: int diff --git a/av/audio/layout.pyi b/av/audio/layout.pyi index 9fdf0ac15..41593009f 100644 --- a/av/audio/layout.pyi +++ b/av/audio/layout.pyi @@ -1,5 +1,7 @@ from dataclasses import dataclass +from typing import final +@final class AudioLayout: name: str nb_channels: int diff --git a/av/audio/plane.pyi b/av/audio/plane.pyi index b3e947937..4a3ccbe26 100644 --- a/av/audio/plane.pyi +++ b/av/audio/plane.pyi @@ -1,3 +1,6 @@ +from typing import final + from av.plane import Plane +@final class AudioPlane(Plane): ... diff --git a/av/audio/resampler.pyi b/av/audio/resampler.pyi index 5e92a4cd9..357899762 100644 --- a/av/audio/resampler.pyi +++ b/av/audio/resampler.pyi @@ -1,9 +1,12 @@ +from typing import final + from av.filter.graph import Graph from .format import AudioFormat from .frame import AudioFrame from .layout import AudioLayout +@final class AudioResampler: rate: int frame_size: int diff --git a/av/audio/stream.pyi b/av/audio/stream.pyi index 835b742d2..6991a27f8 100644 --- a/av/audio/stream.pyi +++ b/av/audio/stream.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterator -from typing import Literal +from typing import Literal, final from av.codec.codec import Codec from av.packet import Packet @@ -18,6 +18,7 @@ class _Layout: def __get__(self, i: object | None, owner: type | None = None) -> AudioLayout: ... def __set__(self, instance: object, value: AudioLayout | str) -> None: ... +@final class AudioStream(Stream): codec_context: AudioCodecContext def encode(self, frame: AudioFrame | None = None) -> list[Packet]: ... diff --git a/av/bitstream.pyi b/av/bitstream.pyi index 34adc16bf..1a6416b76 100644 --- a/av/bitstream.pyi +++ b/av/bitstream.pyi @@ -1,7 +1,10 @@ +from typing import final + from .codec import Codec from .packet import Packet from .stream import Stream +@final class BitStreamFilterContext: def __init__( self, diff --git a/av/codec/codec.pyi b/av/codec/codec.pyi index 46d061d84..9392be5ed 100644 --- a/av/codec/codec.pyi +++ b/av/codec/codec.pyi @@ -1,6 +1,6 @@ from collections.abc import Sequence from enum import Flag, IntEnum, IntFlag -from typing import ClassVar, Literal, cast, overload +from typing import ClassVar, Literal, cast, final, overload from av.audio.codeccontext import AudioCodecContext from av.audio.format import AudioFormat @@ -56,6 +56,7 @@ class PixFmtLoss(IntFlag): class UnknownCodecError(ValueError): ... +@final class Codec: @property def is_encoder(self) -> bool: ... diff --git a/av/codec/hwaccel.pyi b/av/codec/hwaccel.pyi index 48b113d64..fe254936b 100644 --- a/av/codec/hwaccel.pyi +++ b/av/codec/hwaccel.pyi @@ -1,5 +1,5 @@ from enum import IntEnum, IntFlag -from typing import cast +from typing import cast, final from av.codec.codec import Codec from av.video.format import VideoFormat @@ -28,6 +28,7 @@ class HWConfigMethod(IntFlag): internal = cast(int, ...) ad_hoc = cast(int, ...) +@final class HWConfig: @property def device_type(self) -> HWDeviceType: ... @@ -38,6 +39,7 @@ class HWConfig: @property def is_supported(self) -> bool: ... +@final class HWDevice: options: dict[str, object] flags: int @@ -52,6 +54,7 @@ class HWDevice: @property def device_type(self) -> HWDeviceType: ... +@final class HWAccel: options: dict[str, object] flags: int diff --git a/av/dictionary.pyi b/av/dictionary.pyi index f68003c6a..5f67d1f88 100644 --- a/av/dictionary.pyi +++ b/av/dictionary.pyi @@ -1,9 +1,11 @@ from collections.abc import Iterable, Iterator, Mapping +from typing import final +@final class Dictionary: - def __getitem__(self, key: str) -> str: ... - def __setitem__(self, key: str, value: str) -> None: ... - def __delitem__(self, key: str) -> None: ... + def __getitem__(self, key: str, /) -> str: ... + def __setitem__(self, key: str, value: str, /) -> None: ... + def __delitem__(self, key: str, /) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... def __repr__(self) -> str: ... diff --git a/av/filter/context.pyi b/av/filter/context.pyi index 4c6856678..4753118f2 100644 --- a/av/filter/context.pyi +++ b/av/filter/context.pyi @@ -1,8 +1,11 @@ +from typing import final + from av.filter import Graph from av.filter.filter import Filter from av.filter.link import FilterContextPad from av.frame import Frame +@final class FilterContext: name: str | None filter: Filter diff --git a/av/filter/filter.pyi b/av/filter/filter.pyi index dd03d3eef..083bd0d1a 100644 --- a/av/filter/filter.pyi +++ b/av/filter/filter.pyi @@ -1,5 +1,8 @@ +from typing import final + from .link import FilterPad +@final class Filter: name: str description: str diff --git a/av/filter/graph.pyi b/av/filter/graph.pyi index 2ce85df36..4378e6839 100644 --- a/av/filter/graph.pyi +++ b/av/filter/graph.pyi @@ -1,5 +1,5 @@ from fractions import Fraction -from typing import Any +from typing import Any, final from av.audio.format import AudioFormat from av.audio.frame import AudioFrame @@ -14,6 +14,7 @@ from av.video.stream import VideoStream from .context import FilterContext from .filter import Filter +@final class Graph: configured: bool threads: int diff --git a/av/filter/link.pyi b/av/filter/link.pyi index 5c5212b66..f7e88721d 100644 --- a/av/filter/link.pyi +++ b/av/filter/link.pyi @@ -1,3 +1,5 @@ +from typing import final + from av.filter.context import FilterContext from av.filter.filter import Filter from av.filter.graph import Graph @@ -7,7 +9,7 @@ class FilterPad: context: FilterContext | None is_input: bool index: int - def __eq__(self, other: object) -> bool: ... + def __eq__(self, other: object, /) -> bool: ... def __hash__(self) -> int: ... @property def is_output(self) -> bool: ... @@ -16,6 +18,7 @@ class FilterPad: @property def type(self) -> str: ... +@final class FilterContextPad(FilterPad): context: FilterContext @property @@ -23,6 +26,7 @@ class FilterContextPad(FilterPad): @property def linked(self) -> FilterContextPad | None: ... +@final class FilterLink: @property def graph(self) -> Graph: ... diff --git a/av/format.pyi b/av/format.pyi index 7223bab5e..8e481f0ef 100644 --- a/av/format.pyi +++ b/av/format.pyi @@ -1,7 +1,7 @@ __all__ = ("Flags", "ContainerFormat", "formats_available") from enum import Flag -from typing import ClassVar, Literal, cast +from typing import ClassVar, Literal, cast, final class Flags(Flag): no_file = cast(ClassVar[Flags], ...) @@ -22,6 +22,7 @@ class Flags(Flag): ts_negative = cast(ClassVar[Flags], ...) seek_to_pts = cast(ClassVar[Flags], ...) +@final class ContainerFormat: def __init__(self, name: str, mode: Literal["r", "w"] | None = None) -> None: ... @property diff --git a/av/index.pyi b/av/index.pyi index 1ccec7a66..129288e7d 100644 --- a/av/index.pyi +++ b/av/index.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterator -from typing import overload +from typing import final, overload +@final class IndexEntry: pos: int timestamp: int @@ -10,13 +11,14 @@ class IndexEntry: size: int min_distance: int +@final class IndexEntries: def __len__(self) -> int: ... def __iter__(self) -> Iterator[IndexEntry]: ... @overload - def __getitem__(self, index: int) -> IndexEntry: ... + def __getitem__(self, index: int, /) -> IndexEntry: ... @overload - def __getitem__(self, index: slice) -> list[IndexEntry]: ... + def __getitem__(self, index: slice, /) -> list[IndexEntry]: ... def search_timestamp( self, timestamp, *, backward: bool = True, any_frame: bool = False ) -> int: ... diff --git a/av/logging.pyi b/av/logging.pyi index 6193ad7b8..96d6778f3 100644 --- a/av/logging.pyi +++ b/av/logging.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any +from typing import Any, final PANIC: int FATAL: int @@ -21,6 +21,7 @@ def set_skip_repeated(v: bool) -> None: ... def get_last_error() -> tuple[int, tuple[int, str, str] | None]: ... def log(level: int, name: str, message: str) -> None: ... +@final class Capture: logs: list[tuple[int, str, str]] diff --git a/av/packet.pyi b/av/packet.pyi index add0a78d5..72056e739 100644 --- a/av/packet.pyi +++ b/av/packet.pyi @@ -1,6 +1,6 @@ from collections.abc import Iterator from fractions import Fraction -from typing import Generic, Literal, TypeVar, overload +from typing import Generic, Literal, TypeVar, final, overload from av.audio.frame import AudioFrame from av.audio.stream import AudioStream @@ -61,6 +61,7 @@ PktSideDataT = Literal[ "hevc_conf", ] +@final class PacketSideData(Buffer): @staticmethod def from_packet(packet: Packet[Stream], dtype: PktSideDataT) -> PacketSideData: ... @@ -79,6 +80,7 @@ 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]): stream: StreamT stream_index: int diff --git a/av/rational.pyi b/av/rational.pyi index ac8a29b5b..a264baee7 100644 --- a/av/rational.pyi +++ b/av/rational.pyi @@ -1,7 +1,8 @@ from fractions import Fraction from numbers import Rational -from typing import Any, overload +from typing import Any, final, overload +@final class AVRational: num: int den: int @@ -13,29 +14,29 @@ class AVRational: def __bool__(self) -> bool: ... def __float__(self) -> float: ... def __hash__(self) -> int: ... - def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> bool: ... - def __le__(self, other: Any) -> bool: ... - def __gt__(self, other: Any) -> bool: ... - def __ge__(self, other: Any) -> bool: ... + def __eq__(self, other: Any, /) -> bool: ... + def __lt__(self, other: Any, /) -> bool: ... + def __le__(self, other: Any, /) -> bool: ... + def __gt__(self, other: Any, /) -> bool: ... + def __ge__(self, other: Any, /) -> bool: ... def __neg__(self) -> AVRational: ... - def __mul__(self, other: Any) -> AVRational | Fraction | float: ... + def __mul__(self, other: Any, /) -> AVRational | Fraction | float: ... @overload - def __rmul__(self, other: int | Fraction) -> Fraction: ... + def __rmul__(self, other: int | Fraction, /) -> Fraction: ... @overload - def __rmul__(self, other: float) -> float: ... - def __truediv__(self, other: Any) -> AVRational | Fraction | float: ... + def __rmul__(self, other: float, /) -> float: ... + def __truediv__(self, other: Any, /) -> AVRational | Fraction | float: ... @overload - def __rtruediv__(self, other: int | Fraction) -> Fraction: ... + def __rtruediv__(self, other: int | Fraction, /) -> Fraction: ... @overload - def __rtruediv__(self, other: float) -> float: ... - def __add__(self, other: Any) -> AVRational | Fraction | float: ... + def __rtruediv__(self, other: float, /) -> float: ... + def __add__(self, other: Any, /) -> AVRational | Fraction | float: ... @overload - def __radd__(self, other: int | Fraction) -> Fraction: ... + def __radd__(self, other: int | Fraction, /) -> Fraction: ... @overload - def __radd__(self, other: float) -> float: ... - def __sub__(self, other: Any) -> AVRational | Fraction | float: ... + def __radd__(self, other: float, /) -> float: ... + def __sub__(self, other: Any, /) -> AVRational | Fraction | float: ... @overload - def __rsub__(self, other: int | Fraction) -> Fraction: ... + def __rsub__(self, other: int | Fraction, /) -> Fraction: ... @overload - def __rsub__(self, other: float) -> float: ... + def __rsub__(self, other: float, /) -> float: ... diff --git a/av/stream.pyi b/av/stream.pyi index a83af5b81..d5b7b7559 100644 --- a/av/stream.pyi +++ b/av/stream.pyi @@ -1,6 +1,6 @@ from enum import IntEnum, IntFlag from fractions import Fraction -from typing import Literal, cast +from typing import Literal, cast, final from av.rational import AVRational @@ -61,11 +61,13 @@ class Stream: language: str | None type: Literal["video", "audio", "data", "subtitle", "attachment", "unknown"] +@final class DataStream(Stream): codec_context: None type: Literal["data"] name: str | None +@final class AttachmentStream(Stream): codec_context: None type: Literal["attachment"] diff --git a/av/video/format.pyi b/av/video/format.pyi index 8031a103c..ff2ee2e79 100644 --- a/av/video/format.pyi +++ b/av/video/format.pyi @@ -1,3 +1,6 @@ +from typing import final + +@final class VideoFormat: name: str bits_per_pixel: int @@ -18,6 +21,7 @@ class VideoFormat: def chroma_width(self, luma_width: int = 0) -> int: ... def chroma_height(self, luma_height: int = 0) -> int: ... +@final class VideoFormatComponent: index: int plane: int diff --git a/av/video/frame.pyi b/av/video/frame.pyi index 4704cbfe5..79dcf4738 100644 --- a/av/video/frame.pyi +++ b/av/video/frame.pyi @@ -1,6 +1,6 @@ from enum import IntEnum from pathlib import Path -from typing import Any +from typing import Any, final import numpy as np @@ -29,6 +29,7 @@ class PictureType(IntEnum): SP = 6 BI = 7 +@final class CudaContext: @property def device_id(self) -> int: ... @@ -46,6 +47,7 @@ class CudaContext: cuda_stream: int | None = None, ) -> None: ... +@final class VideoFrame(Frame): format: VideoFormat planes: tuple[VideoPlane, ...] diff --git a/av/video/plane.pyi b/av/video/plane.pyi index fcbf8e6ed..7e90261f1 100644 --- a/av/video/plane.pyi +++ b/av/video/plane.pyi @@ -1,9 +1,11 @@ from types import CapsuleType +from typing import final from av.plane import Plane from .frame import VideoFrame +@final class VideoPlane(Plane): line_size: int width: int diff --git a/av/video/reformatter.pyi b/av/video/reformatter.pyi index 584c77452..2e9e63b66 100644 --- a/av/video/reformatter.pyi +++ b/av/video/reformatter.pyi @@ -1,5 +1,5 @@ from enum import IntEnum, IntFlag -from typing import cast +from typing import cast, final from .frame import VideoFrame @@ -93,6 +93,7 @@ class ChromaLocation(IntEnum): BOTTOMLEFT = cast(int, ...) BOTTOM = cast(int, ...) +@final class VideoReformatter: def reformat( self, diff --git a/av/video/stream.pyi b/av/video/stream.pyi index 98f7a879c..1f681df12 100644 --- a/av/video/stream.pyi +++ b/av/video/stream.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterator, Sequence -from typing import Literal +from typing import Literal, final from av.codec.codec import Codec from av.codec.context import ThreadType @@ -11,6 +11,7 @@ from .codeccontext import VideoCodecContext from .format import VideoFormat from .frame import VideoFrame +@final class VideoStream(Stream): bit_rate: int | None max_bit_rate: int | None