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 type hint for packet, is_annexb #1380

Merged
merged 1 commit into from
Apr 18, 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
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
Loading