Add missing defaults to third-party stubs (#14617)

This commit is contained in:
Jelle Zijlstra
2025-08-21 13:36:29 -07:00
committed by GitHub
parent 82926783a4
commit 573b57d8da
54 changed files with 383 additions and 376 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ class YoutubeDL:
cache: Cache
format_selector: _FormatSelector
archive: set[str]
def __init__(self, params: _Params | None = ..., auto_init: bool = ...) -> None: ...
def __init__(self, params: _Params | None = None, auto_init: bool = True) -> None: ...
def warn_if_short_id(self, argv: list[str]) -> None: ...
def add_info_extractor(self, ie: InfoExtractor) -> None: ...
def get_info_extractor(self, ie_key: str) -> InfoExtractor: ...
+2 -2
View File
@@ -252,5 +252,5 @@ class _ParsedOptions(NamedTuple):
urls: Collection[str]
ydl_opts: _Params
def parse_options(argv: Collection[str] | None = ...) -> _ParsedOptions: ...
def main(argv: list[str] | None = ...) -> int: ...
def parse_options(argv: Collection[str] | None = None) -> _ParsedOptions: ...
def main(argv: list[str] | None = None) -> int: ...
+9 -9
View File
@@ -32,8 +32,8 @@ class YDLLogger(_LoggerProtocol):
class CookieLoadError(YoutubeDLError): ...
class YoutubeDLCookieJar(MozillaCookieJar):
def __init__(self, filename: str | None = ..., delayload: bool = False, policy: CookiePolicy | None = None) -> None: ...
def open(self, file: str, *, write: bool = ...) -> Iterator[TextIO]: ...
def __init__(self, filename: str | None = None, delayload: bool = False, policy: CookiePolicy | None = None) -> None: ...
def open(self, file: str, *, write: bool = False) -> Iterator[TextIO]: ...
def get_cookie_header(self, url: str) -> str: ...
def get_cookies_for_url(self, url: str) -> list[Cookie]: ...
def load(self, filename: str | None = None, ignore_discard: bool = True, ignore_expires: bool = True) -> None: ...
@@ -42,11 +42,11 @@ class YoutubeDLCookieJar(MozillaCookieJar):
def load_cookies(cookie_file: str, browser_specification: str | None, ydl: YoutubeDL) -> YoutubeDLCookieJar: ...
def extract_cookies_from_browser(
browser_name: str,
profile: str | None = ...,
profile: str | None = None,
logger: _LoggerProtocol = ...,
*,
keyring: _LinuxKeyring | None = ...,
container: str | None = ...,
keyring: _LinuxKeyring | None = None,
container: str | None = None,
) -> YoutubeDLCookieJar: ...
_T = TypeVar("_T", bound=MozillaCookieJar)
@@ -62,8 +62,8 @@ class LinuxChromeCookieDecryptor(ChromeCookieDecryptor):
browser_keyring_name: str,
logger: _LoggerProtocol,
*,
keyring: _LinuxKeyring | None = ...,
meta_version: int | None = ...,
keyring: _LinuxKeyring | None = None,
meta_version: int | None = None,
) -> None: ...
@staticmethod
def derive_key(password: bytes) -> bytes: ...
@@ -81,8 +81,8 @@ def get_cookie_decryptor(
browser_keyring_name: str,
logger: _LoggerProtocol,
*,
keyring: _LinuxKeyring | None = ...,
meta_version: int | None = ...,
keyring: _LinuxKeyring | None = None,
meta_version: int | None = None,
) -> ChromeCookieDecryptor: ...
class ParserError(Exception): ...
+1 -1
View File
@@ -23,7 +23,7 @@ _Protocol: TypeAlias = Literal[
def get_suitable_downloader(
info_dict: _InfoDict,
params: Mapping[str, Any] = ...,
params: Mapping[str, Any] = {},
default: FileDownloader | type[NO_DEFAULT] = ...,
protocol: _Protocol | None = None,
to_stdout: bool = False,
+113 -108
View File
@@ -175,11 +175,11 @@ class InfoExtractor:
@staticmethod
def playlist_result(
entries: Iterable[_InfoDict],
playlist_id: str | None = ...,
playlist_title: str | None = ...,
playlist_description: str | None = ...,
playlist_id: str | None = None,
playlist_title: str | None = None,
playlist_description: str | None = None,
*,
multi_video: bool = ...,
multi_video: bool = False,
**kwargs: Any, # Added to the dict return value.
) -> _InfoDict: ...
def http_scheme(self) -> str: ...
@@ -197,112 +197,112 @@ class InfoExtractor:
def description(cls, *, markdown: bool = True, search_examples: Sequence[str] | None = None) -> str: ...
# Calls _get_subtitles which only raises NotImplementedError here.
def extract_subtitles(self, *args: Any, **kwargs: Any) -> list[dict[str, Any]]: ...
def _configuration_arg(self, key: str, default: Any = ..., *, ie_key: str | None = ..., casesense: bool = ...) -> Any: ...
def _configuration_arg(self, key: str, default: Any = ..., *, ie_key: str | None = None, casesense: bool = False) -> Any: ...
# These are dynamically created.
def _download_xml_handle(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
impersonate: str | None = ...,
require_impersonation: bool = ...,
note: str | None = "Downloading XML",
errnote: str | None = "Unable to download XML",
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
encoding: str | None = None,
data: _DataType | None = None,
headers: Mapping[str, str] = {},
query: Mapping[str, str] = {},
expected_status: int | None = None,
impersonate: str | None = None,
require_impersonation: bool = False,
) -> tuple[ET.ElementTree, Response]: ...
def _download_xml(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
impersonate: str | None = ...,
require_impersonation: bool = ...,
note: str | None = "Downloading XML",
errnote: str | None = "Unable to download XML",
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
encoding: str | None = None,
data: _DataType | None = None,
headers: Mapping[str, str] = {},
query: Mapping[str, str] = {},
expected_status: int | None = None,
impersonate: str | None = None,
require_impersonation: bool = False,
) -> ET.ElementTree: ...
def _download_socket_json_handle(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
impersonate: str | None = ...,
require_impersonation: bool = ...,
note: str | None = "Polling socket",
errnote: str | None = "Unable to poll socket",
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
encoding: str | None = None,
data: _DataType | None = None,
headers: Mapping[str, str] = {},
query: Mapping[str, str] = {},
expected_status: int | None = None,
impersonate: str | None = None,
require_impersonation: bool = False,
) -> tuple[dict[str, Any], Response]: ...
def _download_socket_json(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
impersonate: str | None = ...,
require_impersonation: bool = ...,
note: str | None = "Polling socket",
errnote: str | None = "Unable to poll socket",
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
encoding: str | None = None,
data: _DataType | None = None,
headers: Mapping[str, str] = {},
query: Mapping[str, str] = {},
expected_status: int | None = None,
impersonate: str | None = None,
require_impersonation: bool = False,
) -> dict[str, Any]: ...
def _download_json_handle(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
impersonate: str | None = ...,
require_impersonation: bool = ...,
note: str | None = "Downloading JSON metadata",
errnote: str | None = "Unable to download JSON metadata",
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
encoding: str | None = None,
data: _DataType | None = None,
headers: Mapping[str, str] = {},
query: Mapping[str, str] = {},
expected_status: int | None = None,
impersonate: str | None = None,
require_impersonation: bool = False,
) -> tuple[dict[str, Any], Response]: ...
def _download_json(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
impersonate: str | None = ...,
require_impersonation: bool = ...,
note: str | None = "Downloading JSON metadata",
errnote: str | None = "Unable to download JSON metadata",
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
encoding: str | None = None,
data: _DataType | None = None,
headers: Mapping[str, str] = {},
query: Mapping[str, str] = {},
expected_status: int | None = None,
impersonate: str | None = None,
require_impersonation: bool = False,
) -> dict[str, Any]: ...
def _download_webpage(
self,
url_or_request: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
note: str | None = None,
errnote: str | None = None,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
fatal: bool = True,
encoding: str | None = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
@@ -315,9 +315,9 @@ class InfoExtractor:
self,
xml_string: str,
video_id: str,
transform_source: Callable[..., str] | None = ...,
fatal: bool = ...,
errnote: str | None = ...,
transform_source: Callable[..., str] | None = None,
fatal: bool = True,
errnote: str | None = None,
) -> ET.Element: ...
def _parse_mpd_formats(
self, mpd_doc: ET.Element, mpd_id: str | None = ..., mpd_base_url: str = ..., mpd_url: str | None = ...
@@ -325,23 +325,23 @@ class InfoExtractor:
def _real_extract(self, url: str) -> _InfoDict: ...
@staticmethod
def _availability(
is_private: bool | None = ...,
needs_premium: bool | None = ...,
needs_subscription: bool | None = ...,
needs_auth: bool | None = ...,
is_unlisted: bool | None = ...,
is_private: bool | None = None,
needs_premium: bool | None = None,
needs_subscription: bool | None = None,
needs_auth: bool | None = None,
is_unlisted: bool | None = None,
) -> Literal["needs_auth", "premium_only", "private", "public", "subscriber_only", "unlisted"] | None: ...
def _request_webpage(
self,
url_or_req: str | Request,
video_id: str,
note: str | None = ...,
errnote: str | None = ...,
fatal: bool = ...,
data: _DataType | None = ...,
headers: Mapping[str, str] = ...,
query: Mapping[str, str] = ...,
expected_status: int | None = ...,
note: str | None = None,
errnote: str | None = None,
fatal: bool = True,
data: _DataType | None = None,
headers: Mapping[str, str] | None = None,
query: Mapping[str, str] | None = None,
expected_status: int | None = None,
) -> Response | Literal[False]: ...
@classmethod
def _match_id(cls, url: str) -> str: ...
@@ -467,7 +467,7 @@ class InfoExtractor:
def _check_formats(self, formats: list[dict[str, Any]], video_id: str) -> None: ...
@staticmethod
def _remove_duplicate_formats(formats: list[dict[str, Any]]) -> None: ...
def _is_valid_url(self, url: str, video_id: str, item: str = "video", headers: Mapping[str, Any] = ...) -> bool: ...
def _is_valid_url(self, url: str, video_id: str, item: str = "video", headers: Mapping[str, Any] = {}) -> bool: ...
def _proto_relative_url(self, url: str, scheme: str | None = None) -> str: ...
def _sleep(self, timeout: float, video_id: str, msg_template: str | None = None) -> None: ...
def _extract_f4m_formats(
@@ -481,8 +481,8 @@ class InfoExtractor:
fatal: bool = True,
m3u8_id: str | None = None,
data: str | None = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
) -> list[dict[str, Any]]: ...
def _parse_f4m_formats(
self,
@@ -531,8 +531,8 @@ class InfoExtractor:
fatal: bool = True,
live: bool = False,
data: Any = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
def _parse_m3u8_formats_and_subtitles(
self,
@@ -548,8 +548,8 @@ class InfoExtractor:
errnote: str | None = None,
fatal: bool = True,
data: Any = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
video_id: str | None = None,
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
def _extract_m3u8_vod_duration(
@@ -559,8 +559,8 @@ class InfoExtractor:
note: str | None = None,
errnote: str | None = None,
data: Any = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
) -> int | None: ...
def _parse_m3u8_vod_duration(self, m3u8_vod: str, video_id: str) -> int: ...
def _extract_mpd_vod_duration(
@@ -570,8 +570,8 @@ class InfoExtractor:
note: str | None = None,
errnote: str | None = None,
data: Any = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
) -> int | None: ...
@staticmethod
def _xpath_ns(path: str, namespace: str | None = None) -> str: ...
@@ -660,8 +660,8 @@ class InfoExtractor:
errnote: str | None = None,
fatal: bool = True,
data: Any = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
) -> tuple[list[Any], dict[str, Any]]: ...
def _parse_mpd_formats_and_subtitles(
self,
@@ -700,8 +700,8 @@ class InfoExtractor:
errnote: str | None = None,
fatal: bool = True,
data: Any = None,
headers: Mapping[str, Any] = ...,
query: Mapping[str, Any] = ...,
headers: Mapping[str, Any] = {},
query: Mapping[str, Any] = {},
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
def _parse_ism_formats_and_subtitles(
self, ism_doc: str, ism_url: str, ism_id: str | None = None
@@ -722,10 +722,10 @@ class InfoExtractor:
self, manifest_url: str, video_id: str, hosts: Mapping[str, Any] = ...
) -> list[dict[str, Any]]: ...
def _extract_akamai_formats_and_subtitles(
self, manifest_url: str, video_id: str, hosts: Mapping[str, Any] = ...
self, manifest_url: str, video_id: str, hosts: Mapping[str, Any] = {}
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
def _extract_wowza_formats(
self, url: str, video_id: str, m3u8_entry_protocol: str = "m3u8_native", skip_protocols: Collection[str] = ...
self, url: str, video_id: str, m3u8_entry_protocol: str = "m3u8_native", skip_protocols: Collection[str] = []
) -> list[dict[str, Any]]: ...
def _find_jwplayer_data(
self, webpage: str, video_id: str | None = None, transform_source: Callable[..., str] = ...
@@ -786,7 +786,7 @@ class InfoExtractor:
path: str = "/",
secure: bool = False,
discard: bool = False,
rest: dict[str, Any] = ...,
rest: dict[str, Any] = {},
**kwargs: Unused,
) -> None: ...
def _live_title(self, name: _T) -> _T: ...
@@ -841,7 +841,12 @@ class InfoExtractor:
) -> bool: ...
def _error_or_warning(self, err: str, _count: int | None = None, _retries: int = 0, *, fatal: bool = True) -> None: ...
def _extract_generic_embeds(
self, url: str, *args: Unused, info_dict: _InfoDict = ..., note: str = "Extracting generic embeds", **kwargs: Unused
self,
url: str,
*args: Unused,
info_dict: _InfoDict = {}, # type: ignore[typeddict-item] # pyright: ignore[reportArgumentType]
note: str = "Extracting generic embeds",
**kwargs: Unused,
) -> list[dict[str, Any]]: ...
@classmethod
def _extract_from_webpage(cls, url: str, webpage: str) -> Iterator[_InfoDict]: ...
+2 -2
View File
@@ -7,7 +7,7 @@ CONTROL_SEQUENCES: dict[str, str] = ...
def format_text(text: str, f: str) -> str: ...
class MultilinePrinterBase:
def __init__(self, stream: TextIO | None = None, lines: int = ...) -> None: ...
def __init__(self, stream: TextIO | None = None, lines: int = 1) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def print_at_line(self, text: str, pos: int) -> None: ...
@@ -19,5 +19,5 @@ class MultilineLogger(MultilinePrinterBase): ...
class BreaklineStatusPrinter(MultilinePrinterBase): ...
class MultilinePrinter(MultilinePrinterBase):
def __init__(self, stream: TextIO | None = None, lines: int = ..., preserve_output: bool = ...) -> None: ...
def __init__(self, stream: TextIO | None = None, lines: int = 1, preserve_output: bool = True) -> None: ...
def lock(func: Callable[..., object]) -> Callable[..., object]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
+1 -1
View File
@@ -8,6 +8,6 @@ def bytes_to_intlist(bs: bytes) -> list[int]: ...
@deprecated("Use `bytes` instead.")
def intlist_to_bytes(xs: list[int]) -> bytes: ...
@deprecated("Use `yt_dlp.utils.jwt_encode` instead.")
def jwt_encode_hs256(payload_data: Any, key: str, headers: Mapping[str, Any] = ...) -> bytes: ... # Passed to json.dumps().
def jwt_encode_hs256(payload_data: Any, key: str, headers: Mapping[str, Any] = {}) -> bytes: ... # Passed to json.dumps().
compiled_regex_type: type[re.Pattern[Any]]
+5 -5
View File
@@ -355,7 +355,7 @@ def strftime_or_none(timestamp: int, date_format: str = "%Y%m%d", default: str |
def parse_duration(s: str | None) -> float: ...
def prepend_extension(filename: str, ext: str, expected_real_ext: str | None = None) -> str: ...
def replace_extension(filename: str, ext: str, expected_real_ext: str | None = None) -> str: ...
def check_executable(exe: str, args: Iterable[str] = ...) -> str | None: ...
def check_executable(exe: str, args: Iterable[str] = []) -> str | None: ...
def detect_exe_version(output: str, version_re: str | Pattern[str] | None = None, unrecognized: str = "present") -> str: ...
def get_exe_version(
exe: str,
@@ -444,8 +444,8 @@ def variadic(x: _T, allowed_types: Collection[type[Any]] | type[NO_DEFAULT] = ..
def try_call(
*funcs: Callable[..., _T],
expected_type: type[_T] | None = None,
args: Iterable[Any] = ...,
kwargs: Mapping[Hashable, Any] = ...,
args: Iterable[Any] = [],
kwargs: Mapping[Hashable, Any] = {},
) -> _T | None: ...
def try_get(src: Any, getter: Callable[..., _T] | Collection[Callable[..., _T]], expected_type: type[_T] | None = None) -> _T: ...
def filter_dict(dct: Mapping[_K, _V], cndn: Callable[[_K, _V], bool] = ...) -> dict[_K, _V]: ...
@@ -457,7 +457,7 @@ TV_PARENTAL_GUIDELINES: Mapping[str, int]
def parse_age_limit(s: int) -> int | None: ...
def strip_jsonp(code: str) -> str: ...
def js_to_json(code: str, vars: Mapping[str, Any] = ..., *, strict: bool = False) -> str: ...
def js_to_json(code: str, vars: Mapping[str, Any] = {}, *, strict: bool = False) -> str: ...
def qualities(quality_ids: Sequence[int]) -> Callable[[int], int]: ...
POSTPROCESS_WHEN: tuple[str, ...]
@@ -520,7 +520,7 @@ def cli_bool_option(
separator: str | None = None,
) -> Any: ...
def cli_valueless_option(params: _Params, command_option: str, param: str, expected_value: bool = True) -> Any: ...
def cli_configuration_args(argdict: dict[str, Any], keys: Iterable[str], default: Any = ..., use_compat: bool = True) -> Any: ...
def cli_configuration_args(argdict: dict[str, Any], keys: Iterable[str], default: Any = [], use_compat: bool = True) -> Any: ...
class ISO639Utils:
@classmethod