From ef97595d3f3be2ef60a72fc247a59255835ffa1d Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sun, 3 Mar 2024 20:33:45 -0500 Subject: [PATCH] Fix type stubs in subtitle.pyi --- av/subtitles/subtitle.pyi | 14 ++++++-------- tests/test_subtitles.py | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/av/subtitles/subtitle.pyi b/av/subtitles/subtitle.pyi index 4b68aeb66..0363c2399 100644 --- a/av/subtitles/subtitle.pyi +++ b/av/subtitles/subtitle.pyi @@ -1,6 +1,4 @@ -from typing import Any, Iterator, Literal - -from .stream import SubtitleStream +from typing import Iterator, Literal class SubtitleSet: format: int @@ -13,15 +11,15 @@ class SubtitleSet: def __getitem__(self, i: int) -> Subtitle: ... class Subtitle: - type: Literal["none", "bitmap", "text", "ass"] + type: Literal[b"none", b"bitmap", b"text", b"ass"] class BitmapSubtitle(Subtitle): - type: Literal["bitmap"] + type: Literal[b"bitmap"] x: int y: int width: int height: int - nb_colors: Any + nb_colors: int planes: tuple[BitmapSubtitlePlane, ...] class BitmapSubtitlePlane: @@ -30,9 +28,9 @@ class BitmapSubtitlePlane: buffer_size: int class TextSubtitle(Subtitle): - type: Literal["text"] + type: Literal[b"text"] text: str class AssSubtitle(Subtitle): - type: Literal["text"] + type: Literal[b"ass"] ass: str diff --git a/tests/test_subtitles.py b/tests/test_subtitles.py index fc0bf9d8e..c457124f2 100644 --- a/tests/test_subtitles.py +++ b/tests/test_subtitles.py @@ -23,6 +23,7 @@ def test_movtext(self): sub = subset[0] self.assertIsInstance(sub, AssSubtitle) + self.assertEqual(sub.type, b"ass") self.assertEqual(sub.ass, "0,0,Default,,0,0,0,,- Test 1.\\N- Test 2.") def test_vobsub(self): @@ -43,10 +44,12 @@ def test_vobsub(self): sub = subset[0] self.assertIsInstance(sub, BitmapSubtitle) + self.assertEqual(sub.type, b"bitmap") self.assertEqual(sub.x, 259) self.assertEqual(sub.y, 379) self.assertEqual(sub.width, 200) self.assertEqual(sub.height, 24) + self.assertEqual(sub.nb_colors, 4) bms = sub.planes self.assertEqual(len(bms), 1)