Skip to content

Commit b558b06

Browse files
committed
Fix some incorrect type stubs
1 parent 6e9698f commit b558b06

File tree

14 files changed

+97
-92
lines changed

14 files changed

+97
-92
lines changed

av/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
AVError = FFmpegError # noqa: F405
4848

4949
__all__ = (
50+
"__version__",
5051
"time_base",
5152
"library_versions",
5253
"AudioCodecContext",

av/codec/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
from .codec import Capabilities, Codec, Properties, codec_descriptor, codecs_available
22
from .context import CodecContext
3+
4+
__all__ = (
5+
"Capabilities",
6+
"Codec",
7+
"Properties",
8+
"codec_descriptor",
9+
"codecs_available",
10+
"CodecContext",
11+
)

av/codec/context.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Flags2(EnumFlag):
5656

5757
class CodecContext:
5858
extradata: bytes | None
59+
extradata_size: int
5960
is_open: bool
6061
is_encoder: bool
6162
is_decoder: bool
@@ -95,6 +96,7 @@ class CodecContext:
9596
ac_pred: bool
9697
interlaced_me: bool
9798
closed_gop: bool
99+
delay: bool
98100

99101
def open(self, strict: bool = True) -> None: ...
100102
def close(self, strict: bool = True) -> None: ...

av/container/output.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OutputContainer(Container):
2323
@overload
2424
def add_stream(
2525
self,
26-
codec_name: Literal["h264", "mpeg4", "png"],
26+
codec_name: Literal["h264", "mpeg4", "png", "qtrle"],
2727
rate: Fraction | int | float | None = None,
2828
template: None = None,
2929
options: dict[str, str] | None = None,

av/video/codeccontext.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class VideoCodecContext(CodecContext):
1111
format: VideoFormat | None
1212
width: int
1313
height: int
14-
bits_per_codec_sample: int
14+
bits_per_coded_sample: int
1515
pix_fmt: str | None
1616
framerate: Fraction
1717
rate: Fraction

av/video/format.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class VideoFormat:
99
is_rgb: bool
1010
width: int
1111
height: int
12+
components: tuple[VideoFormatComponent, ...]
1213

1314
def __init__(self, name: str, width: int = 0, height: int = 0) -> None: ...
1415
def chroma_width(self, luma_width: int = 0) -> int: ...

av/video/stream.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class VideoStream(Stream):
2121
format: VideoFormat
2222
width: int
2323
height: int
24-
bits_per_codec_sample: int
24+
bits_per_coded_sample: int
2525
pix_fmt: str | None
2626
framerate: Fraction
2727
rate: Fraction

tests/test_audiofifo.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ def test_data(self) -> None:
3333
def test_pts_simple(self) -> None:
3434
fifo = av.AudioFifo()
3535

36-
# ensure __repr__ does not crash
37-
self.assertTrue(
38-
str(fifo).startswith(
39-
"<av.AudioFifo uninitialized, use fifo.write(frame), at 0x"
40-
)
36+
assert str(fifo).startswith(
37+
"<av.AudioFifo uninitialized, use fifo.write(frame), at 0x"
4138
)
4239

4340
iframe = av.AudioFrame(samples=1024)
@@ -47,11 +44,8 @@ def test_pts_simple(self) -> None:
4744

4845
fifo.write(iframe)
4946

50-
# ensure __repr__ was updated
51-
self.assertTrue(
52-
str(fifo).startswith(
53-
"<av.AudioFifo 1024 samples of 48000hz <av.AudioLayout 'stereo'> <av.AudioFormat s16> at 0x"
54-
)
47+
assert str(fifo).startswith(
48+
"<av.AudioFifo 1024 samples of 48000hz <av.AudioLayout 'stereo'> <av.AudioFormat s16> at 0x"
5549
)
5650

5751
oframe = fifo.read(512)

tests/test_codec_context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_skip_frame_default(self):
7272
ctx = Codec("png", "w").create()
7373
assert ctx.skip_frame.name == "DEFAULT"
7474

75-
def test_codec_delay(self):
75+
def test_codec_delay(self) -> None:
7676
with av.open(fate_suite("mkv/codec_delay_opus.mkv")) as container:
7777
assert container.streams.audio[0].codec_context.delay == 312
7878
with av.open(fate_suite("h264/interlaced_crop.mp4")) as container:
@@ -131,7 +131,7 @@ def test_decoder_timebase(self) -> None:
131131
with pytest.raises(RuntimeError):
132132
ctx.time_base = Fraction(1, 25)
133133

134-
def test_encoder_extradata(self):
134+
def test_encoder_extradata(self) -> None:
135135
ctx = av.codec.Codec("h264", "w").create()
136136
assert ctx.extradata is None
137137
assert ctx.extradata_size == 0
@@ -140,7 +140,7 @@ def test_encoder_extradata(self):
140140
assert ctx.extradata == b"123"
141141
assert ctx.extradata_size == 3
142142

143-
def test_encoder_pix_fmt(self):
143+
def test_encoder_pix_fmt(self) -> None:
144144
ctx = av.codec.Codec("h264", "w").create("video")
145145

146146
# valid format
@@ -161,6 +161,7 @@ def test_bits_per_coded_sample(self):
161161
for packet in container.demux(stream):
162162
for frame in packet.decode():
163163
pass
164+
assert isinstance(packet.stream, av.VideoStream)
164165
assert packet.stream.bits_per_coded_sample == 32
165166

166167
with av.open(fate_suite("qtrle/aletrek-rle.mov")) as container:

tests/test_file_probing.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def test_stream_probing(self):
4343
assert stream.bit_rate is None
4444
assert stream.channels == 2
4545
assert stream.codec.name == "aac_latm"
46-
self.assertEqual(
47-
stream.codec.long_name, "AAC LATM (Advanced Audio Coding LATM syntax)"
48-
)
46+
assert stream.codec.long_name == "AAC LATM (Advanced Audio Coding LATM syntax)"
4947
assert stream.format.bits == 32
5048
assert stream.format.name == "fltp"
5149
assert stream.layout.name == "stereo"

0 commit comments

Comments
 (0)