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

Type stub all error exceptions #1428

Merged
merged 1 commit into from
Jun 18, 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
2 changes: 2 additions & 0 deletions av/_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class _Meta(TypedDict):

library_meta: dict[str, _Meta]
library_versions: dict[str, tuple[int, int, int]]

time_base: int
48 changes: 47 additions & 1 deletion av/error.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import builtins

from .enum import EnumItem

classes: dict[int, Exception]
Expand Down Expand Up @@ -58,4 +60,48 @@ class LookupError(FFmpegError): ...
class HTTPError(FFmpegError): ...
class HTTPClientError(FFmpegError): ...
class UndefinedError(FFmpegError): ...
class InvalidDataError(ValueError): ...
class InvalidDataError(FFmpegError, builtins.ValueError): ...
class BugError(FFmpegError, builtins.RuntimeError): ...
class BufferTooSmallError(FFmpegError, builtins.ValueError): ...
class BSFNotFoundError(LookupError): ...
class DecoderNotFoundError(LookupError): ...
class DemuxerNotFoundError(LookupError): ...
class EncoderNotFoundError(LookupError): ...
class ExitError(FFmpegError): ...
class ExternalError(FFmpegError): ...
class FilterNotFoundError(LookupError): ...
class MuxerNotFoundError(LookupError): ...
class OptionNotFoundError(LookupError): ...
class PatchWelcomeError(FFmpegError): ...
class ProtocolNotFoundError(LookupError): ...
class UnknownError(FFmpegError): ...
class ExperimentalError(FFmpegError): ...
class InputChangedError(FFmpegError): ...
class OutputChangedError(FFmpegError): ...
class HTTPBadRequestError(HTTPClientError): ...
class HTTPUnauthorizedError(HTTPClientError): ...
class HTTPForbiddenError(HTTPClientError): ...
class HTTPNotFoundError(HTTPClientError): ...
class HTTPOtherClientError(HTTPClientError): ...
class HTTPServerError(HTTPError): ...
class PyAVCallbackError(FFmpegError, builtins.RuntimeError): ...
class BrokenPipeError(FFmpegError, builtins.BrokenPipeError): ...
class ChildProcessError(FFmpegError, builtins.ChildProcessError): ...
class ConnectionAbortedError(FFmpegError, builtins.ConnectionAbortedError): ...
class ConnectionRefusedError(FFmpegError, builtins.ConnectionRefusedError): ...
class ConnectionResetError(FFmpegError, builtins.ConnectionResetError): ...
class BlockingIOError(FFmpegError, builtins.BlockingIOError): ...
class EOFError(FFmpegError, builtins.EOFError): ...
class FileExistsError(FFmpegError, builtins.FileExistsError): ...
class FileNotFoundError(FFmpegError, builtins.FileNotFoundError): ...
class InterruptedError(FFmpegError, builtins.InterruptedError): ...
class IsADirectoryError(FFmpegError, builtins.IsADirectoryError): ...
class MemoryError(FFmpegError, builtins.MemoryError): ...
class NotADirectoryError(FFmpegError, builtins.NotADirectoryError): ...
class NotImplementedError(FFmpegError, builtins.NotImplementedError): ...
class OverflowError(FFmpegError, builtins.OverflowError): ...
class OSError(FFmpegError, builtins.OSError): ...
class PermissionError(FFmpegError, builtins.PermissionError): ...
class ProcessLookupError(FFmpegError, builtins.ProcessLookupError): ...
class TimeoutError(FFmpegError, builtins.TimeoutError): ...
class ValueError(FFmpegError, builtins.ValueError): ...
2 changes: 0 additions & 2 deletions av/error.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ _extend_builtin("ValueError", (errno.EINVAL, ))
_extend_builtin("MemoryError", (errno.ENOMEM, ))
_extend_builtin("NotImplementedError", (errno.ENOSYS, ))
_extend_builtin("OverflowError", (errno.ERANGE, ))
if IOError is not OSError:
_extend_builtin("IOError", (errno.EIO, ))

# The rest of them (for now)
_extend_builtin("OSError", [code for code in errno.errorcode if code not in classes])
Expand Down
Loading