Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ErrorType a proper Enum #1612

Merged
merged 1 commit into from
Nov 7, 2024
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
7 changes: 4 additions & 3 deletions av/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class EnumType(type):
) -> int | None: ...

class EnumItem:
name: str
value: int

@property
def name(self) -> str: ...
@property
def value(self) -> int: ...
def __int__(self) -> int: ...
def __hash__(self) -> int: ...
def __reduce__(
Expand Down
59 changes: 31 additions & 28 deletions av/error.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import builtins
from enum import Enum

from .enum import EnumItem

Expand All @@ -15,41 +16,43 @@ def err_check(res: int, filename: str | None = None) -> int: ...

BUFFER_TOO_SMALL: EnumItem

class ErrorType(EnumItem):
BSF_NOT_FOUND: int
BUG: int
BUFFER_TOO_SMALL: int
DECODER_NOT_FOUND: int
DEMUXER_NOT_FOUND: int
ENCODER_NOT_FOUND: int
EOF: int
EXIT: int
EXTERNAL: int
FILTER_NOT_FOUND: int
INVALIDDATA: int
MUXER_NOT_FOUND: int
OPTION_NOT_FOUND: int
PATCHWELCOME: int
PROTOCOL_NOT_FOUND: int
UNKNOWN: int
EXPERIMENTAL: int
INPUT_CHANGED: int
OUTPUT_CHANGED: int
HTTP_BAD_REQUEST: int
HTTP_UNAUTHORIZED: int
HTTP_FORBIDDEN: int
HTTP_NOT_FOUND: int
HTTP_OTHER_4XX: int
HTTP_SERVER_ERROR: int
PYAV_CALLBACK: int
class ErrorType(EnumItem, Enum):
BSF_NOT_FOUND: EnumItem
BUG: EnumItem
BUFFER_TOO_SMALL: EnumItem
DECODER_NOT_FOUND: EnumItem
DEMUXER_NOT_FOUND: EnumItem
ENCODER_NOT_FOUND: EnumItem
EOF: EnumItem
EXIT: EnumItem
EXTERNAL: EnumItem
FILTER_NOT_FOUND: EnumItem
INVALIDDATA: EnumItem
MUXER_NOT_FOUND: EnumItem
OPTION_NOT_FOUND: EnumItem
PATCHWELCOME: EnumItem
PROTOCOL_NOT_FOUND: EnumItem
UNKNOWN: EnumItem
EXPERIMENTAL: EnumItem
INPUT_CHANGED: EnumItem
OUTPUT_CHANGED: EnumItem
HTTP_BAD_REQUEST: EnumItem
HTTP_UNAUTHORIZED: EnumItem
HTTP_FORBIDDEN: EnumItem
HTTP_NOT_FOUND: EnumItem
HTTP_OTHER_4XX: EnumItem
HTTP_SERVER_ERROR: EnumItem
PYAV_CALLBACK: EnumItem

tag: bytes
@property
def tag(self) -> bytes: ...

class FFmpegError(Exception):
errno: int
strerror: str
filename: str
log: tuple[int, tuple[int, str, str] | None]
type: ErrorType

def __init__(
self,
Expand Down
Loading