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

Add type stubs for datasets.py #1374

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