From 2c61a99b28639c3410f7456a5ac94e68210059b8 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Fri, 23 Oct 2026 23:51:39 -0400 Subject: [PATCH] Fix stub errors in `hwaccel`, `error`, and `ThreadType` - Remove unused `HWAccel.codec` field, which was never assigned - Add `ErrorType` and `__all__` to `av/error.pyi` - Stub `thread_type` as a property instead of giving `ThreadType` fake `__get__`/`__set__` methods --- av/codec/context.pyi | 7 ++-- av/codec/hwaccel.pxd | 3 -- av/error.pyi | 89 ++++++++++++++++++++++++++++++++++++++++++++ av/video/stream.pyi | 5 ++- 4 files changed, 97 insertions(+), 7 deletions(-) diff --git a/av/codec/context.pyi b/av/codec/context.pyi index e9b5764af..2d24e5746 100644 --- a/av/codec/context.pyi +++ b/av/codec/context.pyi @@ -24,8 +24,6 @@ class ThreadType(Flag): FRAME = cast(ClassVar[ThreadType], ...) SLICE = cast(ClassVar[ThreadType], ...) AUTO = cast(ClassVar[ThreadType], ...) - def __get__(self, i: object | None, owner: type | None = None) -> ThreadType: ... - def __set__(self, instance: object, value: int | str | ThreadType) -> None: ... class Flags(IntEnum): unaligned = cast(int, ...) @@ -145,7 +143,6 @@ class CodecContext: trailing_padding: int stats_in: str | None thread_count: int - thread_type: ThreadType skip_frame: Literal[ "NONE", "DEFAULT", "NONREF", "BIDIR", "NONINTRA", "NONKEY", "ALL" ] @@ -176,6 +173,10 @@ class CodecContext: @property def frame_num(self) -> int: ... @property + def thread_type(self) -> ThreadType: ... + @thread_type.setter + def thread_type(self, value: int | str | ThreadType) -> None: ... + @property def active_thread_type(self) -> ThreadType: ... @property def initial_padding(self) -> int: ... diff --git a/av/codec/hwaccel.pxd b/av/codec/hwaccel.pxd index 9764d9414..7d3b88356 100644 --- a/av/codec/hwaccel.pxd +++ b/av/codec/hwaccel.pxd @@ -1,7 +1,5 @@ cimport libav as lib -from av.codec.codec cimport Codec - cdef class HWConfig: cdef object __weakref__ @@ -18,7 +16,6 @@ cdef class HWDevice: cdef class HWAccel: cdef str _device - cdef readonly Codec codec cdef readonly HWConfig config cdef lib.AVBufferRef *ptr cdef public dict options diff --git a/av/error.pyi b/av/error.pyi index f7fb76099..1a390e0e6 100644 --- a/av/error.pyi +++ b/av/error.pyi @@ -1,7 +1,96 @@ import builtins +from enum import IntEnum + +__all__ = [ + "ErrorType", + "FFmpegError", + "LookupError", + "HTTPError", + "HTTPClientError", + "UndefinedError", + "PermissionError", + "BlockingIOError", + "ChildProcessError", + "ConnectionAbortedError", + "ConnectionRefusedError", + "ConnectionResetError", + "FileExistsError", + "InterruptedError", + "IsADirectoryError", + "FileNotFoundError", + "NotADirectoryError", + "BrokenPipeError", + "ProcessLookupError", + "TimeoutError", + "MemoryError", + "NotImplementedError", + "OverflowError", + "OSError", + "ArgumentError", + "BSFNotFoundError", + "BugError", + "BufferTooSmallError", + "DecoderNotFoundError", + "DemuxerNotFoundError", + "EncoderNotFoundError", + "EOFError", + "ExitError", + "ExternalError", + "FilterNotFoundError", + "InvalidDataError", + "MuxerNotFoundError", + "OptionNotFoundError", + "PatchWelcomeError", + "ProtocolNotFoundError", + "UnknownError", + "ExperimentalError", + "InputChangedError", + "OutputChangedError", + "HTTPBadRequestError", + "HTTPUnauthorizedError", + "HTTPForbiddenError", + "HTTPNotFoundError", + "HTTPTooManyRequestsError", + "HTTPOtherClientError", + "HTTPServerError", + "PyAVCallbackError", +] classes: dict[int, Exception] +class ErrorType(IntEnum): + BSF_NOT_FOUND = ... + BUG = ... + BUFFER_TOO_SMALL = ... + DECODER_NOT_FOUND = ... + DEMUXER_NOT_FOUND = ... + ENCODER_NOT_FOUND = ... + EOF = ... + EXIT = ... + EXTERNAL = ... + FILTER_NOT_FOUND = ... + INVALIDDATA = ... + MUXER_NOT_FOUND = ... + OPTION_NOT_FOUND = ... + PATCHWELCOME = ... + PROTOCOL_NOT_FOUND = ... + UNKNOWN = ... + EXPERIMENTAL = ... + INPUT_CHANGED = ... + OUTPUT_CHANGED = ... + HTTP_BAD_REQUEST = ... + HTTP_UNAUTHORIZED = ... + HTTP_FORBIDDEN = ... + HTTP_NOT_FOUND = ... + HTTP_TOO_MANY_REQUESTS = ... + HTTP_OTHER_4XX = ... + HTTP_SERVER_ERROR = ... + PYAV_CALLBACK = ... + @property + def tag(self) -> bytes: ... + @property + def strerror(self) -> str: ... + def code_to_tag(code: int) -> bytes: ... def tag_to_code(tag: bytes) -> int: ... def err_check(res: int, filename: str | None = None) -> int: ... diff --git a/av/video/stream.pyi b/av/video/stream.pyi index 9be73b477..8e4b4b5c8 100644 --- a/av/video/stream.pyi +++ b/av/video/stream.pyi @@ -29,7 +29,10 @@ class VideoStream(Stream): # from codec context format: VideoFormat thread_count: int - thread_type: ThreadType + @property + def thread_type(self) -> ThreadType: ... + @thread_type.setter + def thread_type(self, value: int | str | ThreadType) -> None: ... width: int height: int bits_per_coded_sample: int