Skip to content

Commit

Permalink
Fix all the type errors mypy complains about
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Mar 5, 2024
1 parent d68fd1c commit ac0353d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion av/audio/stream.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class AudioStream(Stream):
format: AudioFormat
codec_context: AudioCodecContext

def encode(self, frame: AudioFrame | None = None) -> list[Packet]: ...
def encode(self, frame: AudioFrame | None = None) -> list[Packet]: ... # type: ignore[override]
def decode(self, packet: Packet | None = None) -> list[AudioFrame]: ...
2 changes: 2 additions & 0 deletions av/format.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ("ContainerFormat", "formats_available")

from .enum import EnumFlag

class Flags(EnumFlag):
Expand Down
11 changes: 8 additions & 3 deletions av/sidedata/motionvectors.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from typing import Any, Sequence
from typing import Any, Sequence, overload

import numpy as np

from .sidedata import SideData

class MotionVectors(SideData, Sequence[Any]):
def __getitem__(self, index: int) -> MotionVector: ...
class MotionVectors(SideData, Sequence[MotionVector]):
@overload
def __getitem__(self, index: int): ...
@overload
def __getitem__(self, index: slice): ...
@overload
def __getitem__(self, index: int | slice): ...
def __len__(self) -> int: ...
def to_ndarray(self) -> np.ndarray[Any, Any]: ...

Expand Down
11 changes: 10 additions & 1 deletion av/sidedata/sidedata.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Mapping
from typing import Iterator, Sequence, overload

from av.buffer import Buffer
from av.enum import EnumItem
Expand Down Expand Up @@ -27,5 +28,13 @@ class SideData(Buffer):
type: Type
DISPLAYMATRIX: int

class SideDataContainer(Mapping[str, int]):
class SideDataContainer(Mapping):
frame: Frame
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[SideData]: ...
@overload
def __getitem__(self, key: int) -> SideData: ...
@overload
def __getitem__(self, key: slice) -> Sequence[SideData]: ...
@overload
def __getitem__(self, key: int | slice) -> SideData | Sequence[SideData]: ...
2 changes: 1 addition & 1 deletion av/video/stream.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ class VideoStream(Stream):
thread_count: int
thread_type: Any

def encode(self, frame: VideoFrame | None = None) -> list[Packet]: ...
def encode(self, frame: VideoFrame | None = None) -> list[Packet]: ... # type: ignore[override]
def decode(self, packet: Packet | None = None) -> list[VideoFrame]: ...

0 comments on commit ac0353d

Please sign in to comment.