diff --git a/av/audio/format.pyi b/av/audio/format.pyi index ffd68ec4b..f3ef36583 100644 --- a/av/audio/format.pyi +++ b/av/audio/format.pyi @@ -1,4 +1,4 @@ -from typing import final +from typing import Self, final @final class AudioFormat: @@ -11,4 +11,4 @@ class AudioFormat: packed: AudioFormat container_name: str - def __init__(self, name: str | AudioFormat) -> None: ... + def __new__(cls, name: str | AudioFormat) -> Self: ... diff --git a/av/audio/frame.pyi b/av/audio/frame.pyi index e7b95c602..6f7263434 100644 --- a/av/audio/frame.pyi +++ b/av/audio/frame.pyi @@ -1,4 +1,4 @@ -from typing import Any, final +from typing import Any, Self, final import numpy as np @@ -27,13 +27,13 @@ class AudioFrame(Frame): def format(self) -> AudioFormat: ... @property def layout(self) -> AudioLayout: ... - def __init__( - self, + def __new__( + cls, format: AudioFormat | str = "s16", layout: AudioLayout | str = "stereo", samples: int = 0, align: int = 1, - ) -> None: ... + ) -> Self: ... @staticmethod def from_ndarray( array: _SupportedNDarray, diff --git a/av/audio/layout.pyi b/av/audio/layout.pyi index 41593009f..9438292f4 100644 --- a/av/audio/layout.pyi +++ b/av/audio/layout.pyi @@ -1,12 +1,12 @@ from dataclasses import dataclass -from typing import final +from typing import Self, final @final class AudioLayout: name: str nb_channels: int channels: tuple[AudioChannel, ...] - def __init__(self, layout: str | AudioLayout): ... + def __new__(cls, layout: str | AudioLayout) -> Self: ... @dataclass class AudioChannel: diff --git a/av/audio/resampler.pyi b/av/audio/resampler.pyi index e73e158fe..55b41b705 100644 --- a/av/audio/resampler.pyi +++ b/av/audio/resampler.pyi @@ -1,4 +1,4 @@ -from typing import final +from typing import Self, final from .format import AudioFormat from .frame import AudioFrame @@ -14,13 +14,13 @@ class AudioResampler: options: dict[str, str] is_passthrough: bool - def __init__( - self, + def __new__( + cls, format: str | int | AudioFormat | None = None, layout: str | int | AudioLayout | None = None, rate: int | None = None, frame_size: int | None = None, options: dict[str, str] | None = None, threads: int | None = None, - ) -> None: ... + ) -> Self: ... def resample(self, frame: AudioFrame | None) -> list[AudioFrame]: ... diff --git a/av/bitstream.pyi b/av/bitstream.pyi index 709d4a40e..03b7f4151 100644 --- a/av/bitstream.pyi +++ b/av/bitstream.pyi @@ -1,4 +1,4 @@ -from typing import Any, final +from typing import Any, Self, final from .codec import Codec from .packet import Packet @@ -6,12 +6,12 @@ from .stream import Stream @final class BitStreamFilterContext: - def __init__( - self, + def __new__( + cls, filter_description: str | bytes, in_stream: Stream | Codec | str | None = None, out_stream: Stream | None = None, - ): ... + ) -> Self: ... def filter(self, packet: Packet[Any] | None) -> list[Packet[Stream]]: ... def flush(self) -> None: ... diff --git a/av/codec/codec.pyi b/av/codec/codec.pyi index a36c24129..0a4260c49 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 Literal, final, overload +from typing import Literal, Self, final, overload from av.audio.codeccontext import AudioCodecContext from av.audio.format import AudioFormat @@ -103,7 +103,7 @@ class Codec: def experimental(self) -> bool: ... @property def delay(self) -> bool: ... - def __init__(self, name: str, mode: Literal["r", "w"] = "r") -> None: ... + def __new__(cls, name: str, mode: Literal["r", "w"] = "r") -> Self: ... @overload def create(self, kind: Literal["video"]) -> VideoCodecContext: ... @overload diff --git a/av/filter/filter.pyi b/av/filter/filter.pyi index 083bd0d1a..1a7ed9380 100644 --- a/av/filter/filter.pyi +++ b/av/filter/filter.pyi @@ -1,4 +1,4 @@ -from typing import final +from typing import Self, final from .link import FilterPad @@ -12,6 +12,6 @@ class Filter: def inputs(self) -> tuple[FilterPad, ...]: ... @property def outputs(self) -> tuple[FilterPad, ...]: ... - def __init__(self, name: str) -> None: ... + def __new__(cls, name: str) -> Self: ... filters_available: set[str] diff --git a/av/filter/graph.pyi b/av/filter/graph.pyi index 4378e6839..f4df107d3 100644 --- a/av/filter/graph.pyi +++ b/av/filter/graph.pyi @@ -1,5 +1,5 @@ from fractions import Fraction -from typing import Any, final +from typing import Any, Self, final from av.audio.format import AudioFormat from av.audio.frame import AudioFrame @@ -19,7 +19,7 @@ class Graph: configured: bool threads: int - def __init__(self, hw_device: HWDevice | None = None) -> None: ... + def __new__(cls, hw_device: HWDevice | None = None) -> Self: ... @property def hw_device(self) -> HWDevice | None: ... def configure(self, auto_buffer: bool = True, force: bool = False) -> None: ... diff --git a/av/format.pyi b/av/format.pyi index f12da90ee..c2686a925 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 Literal, final +from typing import Literal, Self, final class Flags(Flag): _value_: int @@ -25,7 +25,7 @@ class Flags(Flag): @final class ContainerFormat: - def __init__(self, name: str, mode: Literal["r", "w"] | None = None) -> None: ... + def __new__(cls, name: str, mode: Literal["r", "w"] | None = None) -> Self: ... @property def name(self) -> str: ... @property diff --git a/av/plane.pyi b/av/plane.pyi index ac20a840f..36dee1ae6 100644 --- a/av/plane.pyi +++ b/av/plane.pyi @@ -1,3 +1,5 @@ +from typing import Self + from typing_extensions import disjoint_base from .buffer import Buffer @@ -5,4 +7,4 @@ from .frame import Frame @disjoint_base class Plane(Buffer): - def __init__(self, frame: Frame, index: int) -> None: ... + def __new__(cls, frame: Frame, index: int) -> Self: ... diff --git a/av/video/format.pyi b/av/video/format.pyi index c87c9b28f..9f418c185 100644 --- a/av/video/format.pyi +++ b/av/video/format.pyi @@ -1,4 +1,4 @@ -from typing import final +from typing import Self, final @final class VideoFormat: @@ -17,7 +17,7 @@ class VideoFormat: def is_rgb(self) -> bool: ... @property def is_bayer(self) -> bool: ... - def __init__(self, name: str, width: int = 0, height: int = 0) -> None: ... + def __new__(cls, name: str, width: int = 0, height: int = 0) -> Self: ... def chroma_width(self, luma_width: int = 0) -> int: ... def chroma_height(self, luma_height: int = 0) -> int: ... def __int__(self) -> int: ... @@ -33,6 +33,6 @@ class VideoFormatComponent: width: int height: int - def __init__(self, format: VideoFormat, index: int) -> None: ... + def __new__(cls, format: VideoFormat, index: int) -> Self: ... names: set[str] diff --git a/av/video/frame.pyi b/av/video/frame.pyi index f6a0baf5a..50e75ef26 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, Literal, final, overload +from typing import Any, Literal, Self, final, overload import numpy as np from PIL.Image import Image @@ -40,13 +40,13 @@ class CudaContext: def current_ctx(self) -> bool: ... @property def cuda_stream(self) -> int: ... - def __init__( - self, + def __new__( + cls, device_id: int = 0, primary_ctx: bool = True, current_ctx: bool = False, cuda_stream: int | None = None, - ) -> None: ... + ) -> Self: ... @final class VideoFrame(Frame): @@ -71,9 +71,9 @@ class VideoFrame(Frame): def interlaced_frame(self) -> bool: ... @property def rotation(self) -> int: ... - def __init__( - self, width: int = 0, height: int = 0, format: str = "yuv420p" - ) -> None: ... + def __new__( + cls, width: int = 0, height: int = 0, format: str = "yuv420p" + ) -> Self: ... def reformat( self, width: int | None = None, diff --git a/av/video/plane.pyi b/av/video/plane.pyi index 7e90261f1..3346a6435 100644 --- a/av/video/plane.pyi +++ b/av/video/plane.pyi @@ -1,5 +1,5 @@ from types import CapsuleType -from typing import final +from typing import Self, final from av.plane import Plane @@ -12,6 +12,6 @@ class VideoPlane(Plane): height: int buffer_size: int - def __init__(self, frame: VideoFrame, index: int) -> None: ... + def __new__(cls, frame: VideoFrame, index: int) -> Self: ... def __dlpack_device__(self) -> tuple[int, int]: ... def __dlpack__(self, *, stream: int | None = None) -> CapsuleType: ...