[yt-dlp] Use Final (#14788)

This commit is contained in:
Semyon Moroz
2025-09-26 13:39:27 +04:00
committed by GitHub
parent f97c78550c
commit 6af8f287bb
9 changed files with 68 additions and 66 deletions
+4 -4
View File
@@ -2,15 +2,15 @@ from collections.abc import Collection, Iterator, KeysView
from enum import Enum
from http.cookiejar import Cookie, CookiePolicy, MozillaCookieJar
from http.cookies import SimpleCookie
from typing import TextIO, TypeVar
from typing import Final, TextIO, TypeVar
from . import _LoggerProtocol
from .minicurses import MultilinePrinter
from .utils._utils import YoutubeDLError
from .YoutubeDL import YoutubeDL
CHROMIUM_BASED_BROWSERS: set[str] = ...
SUPPORTED_BROWSERS: set[str] = ...
CHROMIUM_BASED_BROWSERS: Final[set[str]]
SUPPORTED_BROWSERS: Final[set[str]]
class _LinuxKeyring(Enum):
BASICTEXT = 5
@@ -19,7 +19,7 @@ class _LinuxKeyring(Enum):
KWALLET5 = 2
KWALLET6 = 3
SUPPORTED_KEYRINGS: KeysView[str]
SUPPORTED_KEYRINGS: Final[KeysView[str]]
class YDLLogger(_LoggerProtocol):
def warning(self, message: str, only_once: bool = False) -> None: ... # type: ignore[override]
+16 -16
View File
@@ -1,25 +1,25 @@
import struct
from _typeshed import SupportsWrite
from collections.abc import Collection, Mapping
from typing import Any
from typing import Any, Final
from .fragment import FragmentFD
u8: struct.Struct
u88: struct.Struct
u16: struct.Struct
u1616: struct.Struct
u32: struct.Struct
u64: struct.Struct
s88: struct.Struct
s16: struct.Struct
s1616: struct.Struct
s32: struct.Struct
unity_matrix: bytes
TRACK_ENABLED: int
TRACK_IN_MOVIE: int
TRACK_IN_PREVIEW: int
SELF_CONTAINED: int
u8: Final[struct.Struct]
u88: Final[struct.Struct]
u16: Final[struct.Struct]
u1616: Final[struct.Struct]
u32: Final[struct.Struct]
u64: Final[struct.Struct]
s88: Final[struct.Struct]
s16: Final[struct.Struct]
s1616: Final[struct.Struct]
s32: Final[struct.Struct]
unity_matrix: Final[bytes]
TRACK_ENABLED: Final = 0x1
TRACK_IN_MOVIE: Final = 0x2
TRACK_IN_PREVIEW: Final = 0x4
SELF_CONTAINED: Final = 0x1
def box(box_type: bytes, payload: bytes) -> bytes: ...
def full_box(box_type: bytes, version: int, flags: int, payload: bytes) -> bytes: ...
+2 -2
View File
@@ -1,8 +1,8 @@
from collections.abc import Callable
from typing import TextIO
from typing import Final, TextIO
from typing_extensions import Self
CONTROL_SEQUENCES: dict[str, str] = ...
CONTROL_SEQUENCES: Final[dict[str, str]]
def format_text(text: str, f: str) -> str: ...
+2 -2
View File
@@ -5,14 +5,14 @@ from _typeshed import Unused
from collections.abc import Callable, Iterable, Mapping
from email.message import Message
from logging import Logger
from typing import IO, Any
from typing import IO, Any, Final
from typing_extensions import Self, TypeAlias
from ..cookies import YoutubeDLCookieJar
from ..utils._utils import _YDLLogger
from ..utils.networking import HTTPHeaderDict
DEFAULT_TIMEOUT: int
DEFAULT_TIMEOUT: Final = 20
_RequestData: TypeAlias = bytes | Iterable[bytes] | IO[Any] | None
_Preference: TypeAlias = Callable[[RequestHandler, Request], int]
@@ -18,7 +18,7 @@ class ImpersonateTarget:
def from_str(cls, target: str) -> Self: ...
class ImpersonateRequestHandler(RequestHandler, ABC):
_SUPPORTED_IMPERSONATE_TARGET_MAP: dict[ImpersonateTarget, Any] = ... # Copied from source.
_SUPPORTED_IMPERSONATE_TARGET_MAP: dict[ImpersonateTarget, Any] # Copied from source.
def __init__(
self,
+3 -3
View File
@@ -5,7 +5,7 @@ from collections.abc import Iterator
from importlib.machinery import ModuleSpec
from pathlib import Path
from types import ModuleType
from typing import Any
from typing import Any, Final
from .globals import Indirect
@@ -19,8 +19,8 @@ __all__ = [
"register_plugin_spec",
]
PACKAGE_NAME: str = "yt_dlp_plugins"
COMPAT_PACKAGE_NAME: str = "ytdlp_plugins"
PACKAGE_NAME: Final = "yt_dlp_plugins"
COMPAT_PACKAGE_NAME: Final = "ytdlp_plugins"
@dataclasses.dataclass
class PluginSpec:
+7 -7
View File
@@ -1,14 +1,14 @@
import socket
from _socket import _Address
from collections.abc import Mapping
from typing import NamedTuple, SupportsIndex
from typing import Final, NamedTuple, SupportsIndex
SOCKS4_VERSION: int
SOCKS4_REPLY_VERSION: int
SOCKS4_DEFAULT_DSTIP: bytes
SOCKS5_VERSION: int
SOCKS5_USER_AUTH_VERSION: int
SOCKS5_USER_AUTH_SUCCESS: int
SOCKS4_VERSION: Final = 4
SOCKS4_REPLY_VERSION: Final = 0x00
SOCKS4_DEFAULT_DSTIP: Final[bytes]
SOCKS5_VERSION: Final = 5
SOCKS5_USER_AUTH_VERSION: Final = 0x01
SOCKS5_USER_AUTH_SUCCESS: Final = 0x00
class Socks4Command:
CMD_CONNECT: int
+25 -25
View File
@@ -23,7 +23,7 @@ from functools import cache
from optparse import Values
from os import PathLike
from re import Pattern
from typing import IO, Any, AnyStr, BinaryIO, Generic, Literal, NamedTuple, TextIO, TypeVar, overload
from typing import IO, Any, AnyStr, BinaryIO, Final, Generic, Literal, NamedTuple, TextIO, TypeVar, overload
from typing_extensions import Self, TypeAlias
from urllib.parse import _QueryType, _QuoteVia
from xml.etree import ElementTree as ET
@@ -42,16 +42,16 @@ class NO_DEFAULT: ...
def IDENTITY(x: _T) -> _T: ...
ENGLISH_MONTH_NAMES: Sequence[str]
MONTH_NAMES: Mapping[str, Sequence[str]]
TIMEZONE_NAMES: Mapping[str, str]
ACCENT_CHARS: Mapping[str, str]
DATE_FORMATS: Sequence[str]
DATE_FORMATS_DAY_FIRST: Sequence[str]
DATE_FORMATS_MONTH_FIRST: Sequence[str]
PACKED_CODES_RE: str
JSON_LD_RE: str
NUMBER_RE: str
ENGLISH_MONTH_NAMES: Final[Sequence[str]]
MONTH_NAMES: Final[Mapping[str, Sequence[str]]]
TIMEZONE_NAMES: Final[Mapping[str, str]]
ACCENT_CHARS: Final[Mapping[str, str]]
DATE_FORMATS: Final[Sequence[str]]
DATE_FORMATS_DAY_FIRST: Final[Sequence[str]]
DATE_FORMATS_MONTH_FIRST: Final[Sequence[str]]
PACKED_CODES_RE: Final[str]
JSON_LD_RE: Final[str]
NUMBER_RE: Final[str]
@cache
def preferredencoding() -> str: ...
@@ -452,19 +452,19 @@ def filter_dict(dct: Mapping[_K, _V], cndn: Callable[[_K, _V], bool] = ...) -> d
def merge_dicts(*dicts: Mapping[Hashable, Any]) -> dict[Hashable, Any]: ...
def encode_compat_str(string: str, encoding: str = ..., errors: str = "strict") -> str: ...
US_RATINGS: Mapping[str, int]
TV_PARENTAL_GUIDELINES: Mapping[str, int]
US_RATINGS: Final[Mapping[str, int]]
TV_PARENTAL_GUIDELINES: Final[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 qualities(quality_ids: Sequence[int]) -> Callable[[int], int]: ...
POSTPROCESS_WHEN: tuple[str, ...]
DEFAULT_OUTTMPL: Mapping[str, str]
OUTTMPL_TYPES: Mapping[str, str | None]
STR_FORMAT_RE_TMPL: str
STR_FORMAT_TYPES: str
POSTPROCESS_WHEN: Final[tuple[str, ...]]
DEFAULT_OUTTMPL: Final[Mapping[str, str]]
OUTTMPL_TYPES: Final[Mapping[str, str | None]]
STR_FORMAT_RE_TMPL: Final[str]
STR_FORMAT_TYPES: Final[str]
def limit_length(s: str, length: int) -> str: ...
def version_tuple(v: str) -> tuple[int, ...]: ...
@@ -487,7 +487,7 @@ def urlhandle_detect_ext(url_handle: Response, default: str | type[NO_DEFAULT] =
def encode_data_uri(data: ReadableBuffer, mime_type: str) -> str: ...
def age_restricted(content_limit: int | None, age_limit: int | None) -> bool: ...
BOMS: Collection[tuple[bytes, str]]
BOMS: Final[Collection[tuple[bytes, str]]]
def is_html(first_bytes: bytes) -> bool: ...
def determine_protocol(info_dict: _InfoDict) -> str: ...
@@ -551,10 +551,10 @@ def write_xattr(path: FileDescriptorOrPath, key: str, value: str) -> None: ...
def random_birthday(year_field: Hashable, month_field: Hashable, day_field: Hashable) -> dict[Hashable, str]: ...
def find_available_port(interface: str = "") -> Any | None: ...
DOT_URL_LINK_TEMPLATE: str
DOT_WEBLOC_LINK_TEMPLATE: str
DOT_DESKTOP_LINK_TEMPLATE: str
LINK_TEMPLATES: Mapping[str, str]
DOT_URL_LINK_TEMPLATE: Final[str]
DOT_WEBLOC_LINK_TEMPLATE: Final[str]
DOT_DESKTOP_LINK_TEMPLATE: Final[str]
LINK_TEMPLATES: Final[Mapping[str, str]]
def iri_to_uri(iri: str) -> str: ...
def to_high_limit_path(path: PathLike[AnyStr]) -> str: ...
@@ -620,8 +620,8 @@ class Namespace(types.SimpleNamespace):
@property
def items_(self) -> dict[str, Any]: ...
MEDIA_EXTENSIONS: Namespace
KNOWN_EXTENSIONS: tuple[str, ...]
MEDIA_EXTENSIONS: Final[Namespace]
KNOWN_EXTENSIONS: Final[tuple[str, ...]]
class _UnsafeExtensionError(Exception):
ALLOWED_EXTENSIONS: frozenset[str]
+8 -6
View File
@@ -1,6 +1,8 @@
__version__: str
RELEASE_GIT_HEAD: str
VARIANT: str
UPDATE_HINT: str
CHANNEL: str
ORIGIN: str
from typing import Final
__version__: Final[str]
RELEASE_GIT_HEAD: Final[str]
VARIANT: Final[str]
UPDATE_HINT: Final[str]
CHANNEL: Final[str]
ORIGIN: Final[str]