Skip to content

Commit

Permalink
Add type stubs for datasets.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Apr 7, 2024
1 parent c4ca5eb commit 19fab01
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions av/audio/layout.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class AudioLayout:
layout: int
nb_channels: int
channels: tuple[AudioChannel, ...]
def __init__(self, layout: int | str | AudioLayout): ...

class AudioChannel:
name: str
Expand Down
9 changes: 5 additions & 4 deletions av/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import logging
import os
import sys
from typing import Iterator
from urllib.request import urlopen

log = logging.getLogger(__name__)


def iter_data_dirs(check_writable=False):
def iter_data_dirs(check_writable: bool = False) -> Iterator[str]:
try:
yield os.environ["PYAV_TESTDATA_DIR"]
except KeyError:
Expand Down Expand Up @@ -42,7 +43,7 @@ def iter_data_dirs(check_writable=False):
yield os.path.join(os.path.expanduser("~"), ".pyav", "datasets")


def cached_download(url, name):
def cached_download(url: str, name: str) -> str:
"""Download the data at a URL, and cache it under the given name.
The file is stored under `pyav/test` with the given name in the directory
Expand Down Expand Up @@ -96,7 +97,7 @@ def cached_download(url, name):
return path


def fate(name):
def fate(name: str) -> str:
"""Download and return a path to a sample from the FFmpeg test suite.
Data is handled by :func:`cached_download`.
Expand All @@ -110,7 +111,7 @@ def fate(name):
)


def curated(name):
def curated(name: str) -> str:
"""Download and return a path to a sample that is curated by the PyAV developers.
Data is handled by :func:`cached_download`.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_audiolayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_stereo_properties(self):
layout = AudioLayout("stereo")
self._test_stereo(layout)

def test_2channel_properties(self):
def test_2channel_properties(self) -> None:
layout = AudioLayout(2)
self._test_stereo(layout)

Expand Down

0 comments on commit 19fab01

Please sign in to comment.