Skip to content

Commit

Permalink
Make ErrorType a proper Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored and WyattBlue committed Nov 7, 2024
1 parent d7a6eb9 commit 0564862
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
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

0 comments on commit 0564862

Please sign in to comment.