Skip to content

Commit

Permalink
Fix type hint for packet, is_annexb
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Apr 18, 2024
1 parent 21ddc60 commit 829caed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion av/packet.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Buffer
from fractions import Fraction
from typing import Buffer, Iterator
from typing import Iterator

from av.subtitles.subtitle import SubtitleSet

Expand All @@ -22,3 +23,4 @@ class Packet(Buffer):

def __init__(self, input: int | bytes | None = None) -> None: ...
def decode(self) -> Iterator[SubtitleSet]: ...
def __buffer__(self, arg1) -> memoryview: ...
7 changes: 6 additions & 1 deletion tests/test_bitstream.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from __future__ import annotations

import av
from av import Packet
from av.bitstream import BitStreamFilterContext, bitstream_filters_available

from .common import TestCase, fate_suite


def is_annexb(packet: Packet) -> bool:
def is_annexb(packet: Packet | bytes | None) -> bool:
if packet is None:
return False

data = bytes(packet)
return data[:3] == b"\0\0\x01" or data[:4] == b"\0\0\0\x01"

Expand Down

0 comments on commit 829caed

Please sign in to comment.