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

Fix all the type errors mypy complains about #1325

Merged
merged 1 commit into from
Mar 5, 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: 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]: ...
Loading