Skip to content

Commit 6af8f28

Browse files
authored
[yt-dlp] Use Final (#14788)
1 parent f97c785 commit 6af8f28

File tree

9 files changed

+68
-66
lines changed

9 files changed

+68
-66
lines changed

stubs/yt-dlp/yt_dlp/cookies.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ from collections.abc import Collection, Iterator, KeysView
22
from enum import Enum
33
from http.cookiejar import Cookie, CookiePolicy, MozillaCookieJar
44
from http.cookies import SimpleCookie
5-
from typing import TextIO, TypeVar
5+
from typing import Final, TextIO, TypeVar
66

77
from . import _LoggerProtocol
88
from .minicurses import MultilinePrinter
99
from .utils._utils import YoutubeDLError
1010
from .YoutubeDL import YoutubeDL
1111

12-
CHROMIUM_BASED_BROWSERS: set[str] = ...
13-
SUPPORTED_BROWSERS: set[str] = ...
12+
CHROMIUM_BASED_BROWSERS: Final[set[str]]
13+
SUPPORTED_BROWSERS: Final[set[str]]
1414

1515
class _LinuxKeyring(Enum):
1616
BASICTEXT = 5
@@ -19,7 +19,7 @@ class _LinuxKeyring(Enum):
1919
KWALLET5 = 2
2020
KWALLET6 = 3
2121

22-
SUPPORTED_KEYRINGS: KeysView[str]
22+
SUPPORTED_KEYRINGS: Final[KeysView[str]]
2323

2424
class YDLLogger(_LoggerProtocol):
2525
def warning(self, message: str, only_once: bool = False) -> None: ... # type: ignore[override]

stubs/yt-dlp/yt_dlp/downloader/ism.pyi

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import struct
22
from _typeshed import SupportsWrite
33
from collections.abc import Collection, Mapping
4-
from typing import Any
4+
from typing import Any, Final
55

66
from .fragment import FragmentFD
77

8-
u8: struct.Struct
9-
u88: struct.Struct
10-
u16: struct.Struct
11-
u1616: struct.Struct
12-
u32: struct.Struct
13-
u64: struct.Struct
14-
s88: struct.Struct
15-
s16: struct.Struct
16-
s1616: struct.Struct
17-
s32: struct.Struct
18-
unity_matrix: bytes
19-
TRACK_ENABLED: int
20-
TRACK_IN_MOVIE: int
21-
TRACK_IN_PREVIEW: int
22-
SELF_CONTAINED: int
8+
u8: Final[struct.Struct]
9+
u88: Final[struct.Struct]
10+
u16: Final[struct.Struct]
11+
u1616: Final[struct.Struct]
12+
u32: Final[struct.Struct]
13+
u64: Final[struct.Struct]
14+
s88: Final[struct.Struct]
15+
s16: Final[struct.Struct]
16+
s1616: Final[struct.Struct]
17+
s32: Final[struct.Struct]
18+
unity_matrix: Final[bytes]
19+
TRACK_ENABLED: Final = 0x1
20+
TRACK_IN_MOVIE: Final = 0x2
21+
TRACK_IN_PREVIEW: Final = 0x4
22+
SELF_CONTAINED: Final = 0x1
2323

2424
def box(box_type: bytes, payload: bytes) -> bytes: ...
2525
def full_box(box_type: bytes, version: int, flags: int, payload: bytes) -> bytes: ...

stubs/yt-dlp/yt_dlp/minicurses.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from collections.abc import Callable
2-
from typing import TextIO
2+
from typing import Final, TextIO
33
from typing_extensions import Self
44

5-
CONTROL_SEQUENCES: dict[str, str] = ...
5+
CONTROL_SEQUENCES: Final[dict[str, str]]
66

77
def format_text(text: str, f: str) -> str: ...
88

stubs/yt-dlp/yt_dlp/networking/common.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ from _typeshed import Unused
55
from collections.abc import Callable, Iterable, Mapping
66
from email.message import Message
77
from logging import Logger
8-
from typing import IO, Any
8+
from typing import IO, Any, Final
99
from typing_extensions import Self, TypeAlias
1010

1111
from ..cookies import YoutubeDLCookieJar
1212
from ..utils._utils import _YDLLogger
1313
from ..utils.networking import HTTPHeaderDict
1414

15-
DEFAULT_TIMEOUT: int
15+
DEFAULT_TIMEOUT: Final = 20
1616
_RequestData: TypeAlias = bytes | Iterable[bytes] | IO[Any] | None
1717
_Preference: TypeAlias = Callable[[RequestHandler, Request], int]
1818

stubs/yt-dlp/yt_dlp/networking/impersonate.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ImpersonateTarget:
1818
def from_str(cls, target: str) -> Self: ...
1919

2020
class ImpersonateRequestHandler(RequestHandler, ABC):
21-
_SUPPORTED_IMPERSONATE_TARGET_MAP: dict[ImpersonateTarget, Any] = ... # Copied from source.
21+
_SUPPORTED_IMPERSONATE_TARGET_MAP: dict[ImpersonateTarget, Any] # Copied from source.
2222

2323
def __init__(
2424
self,

stubs/yt-dlp/yt_dlp/plugins.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from collections.abc import Iterator
55
from importlib.machinery import ModuleSpec
66
from pathlib import Path
77
from types import ModuleType
8-
from typing import Any
8+
from typing import Any, Final
99

1010
from .globals import Indirect
1111

@@ -19,8 +19,8 @@ __all__ = [
1919
"register_plugin_spec",
2020
]
2121

22-
PACKAGE_NAME: str = "yt_dlp_plugins"
23-
COMPAT_PACKAGE_NAME: str = "ytdlp_plugins"
22+
PACKAGE_NAME: Final = "yt_dlp_plugins"
23+
COMPAT_PACKAGE_NAME: Final = "ytdlp_plugins"
2424

2525
@dataclasses.dataclass
2626
class PluginSpec:

stubs/yt-dlp/yt_dlp/socks.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import socket
22
from _socket import _Address
33
from collections.abc import Mapping
4-
from typing import NamedTuple, SupportsIndex
4+
from typing import Final, NamedTuple, SupportsIndex
55

6-
SOCKS4_VERSION: int
7-
SOCKS4_REPLY_VERSION: int
8-
SOCKS4_DEFAULT_DSTIP: bytes
9-
SOCKS5_VERSION: int
10-
SOCKS5_USER_AUTH_VERSION: int
11-
SOCKS5_USER_AUTH_SUCCESS: int
6+
SOCKS4_VERSION: Final = 4
7+
SOCKS4_REPLY_VERSION: Final = 0x00
8+
SOCKS4_DEFAULT_DSTIP: Final[bytes]
9+
SOCKS5_VERSION: Final = 5
10+
SOCKS5_USER_AUTH_VERSION: Final = 0x01
11+
SOCKS5_USER_AUTH_SUCCESS: Final = 0x00
1212

1313
class Socks4Command:
1414
CMD_CONNECT: int

stubs/yt-dlp/yt_dlp/utils/_utils.pyi

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from functools import cache
2323
from optparse import Values
2424
from os import PathLike
2525
from re import Pattern
26-
from typing import IO, Any, AnyStr, BinaryIO, Generic, Literal, NamedTuple, TextIO, TypeVar, overload
26+
from typing import IO, Any, AnyStr, BinaryIO, Final, Generic, Literal, NamedTuple, TextIO, TypeVar, overload
2727
from typing_extensions import Self, TypeAlias
2828
from urllib.parse import _QueryType, _QuoteVia
2929
from xml.etree import ElementTree as ET
@@ -42,16 +42,16 @@ class NO_DEFAULT: ...
4242

4343
def IDENTITY(x: _T) -> _T: ...
4444

45-
ENGLISH_MONTH_NAMES: Sequence[str]
46-
MONTH_NAMES: Mapping[str, Sequence[str]]
47-
TIMEZONE_NAMES: Mapping[str, str]
48-
ACCENT_CHARS: Mapping[str, str]
49-
DATE_FORMATS: Sequence[str]
50-
DATE_FORMATS_DAY_FIRST: Sequence[str]
51-
DATE_FORMATS_MONTH_FIRST: Sequence[str]
52-
PACKED_CODES_RE: str
53-
JSON_LD_RE: str
54-
NUMBER_RE: str
45+
ENGLISH_MONTH_NAMES: Final[Sequence[str]]
46+
MONTH_NAMES: Final[Mapping[str, Sequence[str]]]
47+
TIMEZONE_NAMES: Final[Mapping[str, str]]
48+
ACCENT_CHARS: Final[Mapping[str, str]]
49+
DATE_FORMATS: Final[Sequence[str]]
50+
DATE_FORMATS_DAY_FIRST: Final[Sequence[str]]
51+
DATE_FORMATS_MONTH_FIRST: Final[Sequence[str]]
52+
PACKED_CODES_RE: Final[str]
53+
JSON_LD_RE: Final[str]
54+
NUMBER_RE: Final[str]
5555

5656
@cache
5757
def preferredencoding() -> str: ...
@@ -452,19 +452,19 @@ def filter_dict(dct: Mapping[_K, _V], cndn: Callable[[_K, _V], bool] = ...) -> d
452452
def merge_dicts(*dicts: Mapping[Hashable, Any]) -> dict[Hashable, Any]: ...
453453
def encode_compat_str(string: str, encoding: str = ..., errors: str = "strict") -> str: ...
454454

455-
US_RATINGS: Mapping[str, int]
456-
TV_PARENTAL_GUIDELINES: Mapping[str, int]
455+
US_RATINGS: Final[Mapping[str, int]]
456+
TV_PARENTAL_GUIDELINES: Final[Mapping[str, int]]
457457

458458
def parse_age_limit(s: int) -> int | None: ...
459459
def strip_jsonp(code: str) -> str: ...
460460
def js_to_json(code: str, vars: Mapping[str, Any] = {}, *, strict: bool = False) -> str: ...
461461
def qualities(quality_ids: Sequence[int]) -> Callable[[int], int]: ...
462462

463-
POSTPROCESS_WHEN: tuple[str, ...]
464-
DEFAULT_OUTTMPL: Mapping[str, str]
465-
OUTTMPL_TYPES: Mapping[str, str | None]
466-
STR_FORMAT_RE_TMPL: str
467-
STR_FORMAT_TYPES: str
463+
POSTPROCESS_WHEN: Final[tuple[str, ...]]
464+
DEFAULT_OUTTMPL: Final[Mapping[str, str]]
465+
OUTTMPL_TYPES: Final[Mapping[str, str | None]]
466+
STR_FORMAT_RE_TMPL: Final[str]
467+
STR_FORMAT_TYPES: Final[str]
468468

469469
def limit_length(s: str, length: int) -> str: ...
470470
def version_tuple(v: str) -> tuple[int, ...]: ...
@@ -487,7 +487,7 @@ def urlhandle_detect_ext(url_handle: Response, default: str | type[NO_DEFAULT] =
487487
def encode_data_uri(data: ReadableBuffer, mime_type: str) -> str: ...
488488
def age_restricted(content_limit: int | None, age_limit: int | None) -> bool: ...
489489

490-
BOMS: Collection[tuple[bytes, str]]
490+
BOMS: Final[Collection[tuple[bytes, str]]]
491491

492492
def is_html(first_bytes: bytes) -> bool: ...
493493
def determine_protocol(info_dict: _InfoDict) -> str: ...
@@ -551,10 +551,10 @@ def write_xattr(path: FileDescriptorOrPath, key: str, value: str) -> None: ...
551551
def random_birthday(year_field: Hashable, month_field: Hashable, day_field: Hashable) -> dict[Hashable, str]: ...
552552
def find_available_port(interface: str = "") -> Any | None: ...
553553

554-
DOT_URL_LINK_TEMPLATE: str
555-
DOT_WEBLOC_LINK_TEMPLATE: str
556-
DOT_DESKTOP_LINK_TEMPLATE: str
557-
LINK_TEMPLATES: Mapping[str, str]
554+
DOT_URL_LINK_TEMPLATE: Final[str]
555+
DOT_WEBLOC_LINK_TEMPLATE: Final[str]
556+
DOT_DESKTOP_LINK_TEMPLATE: Final[str]
557+
LINK_TEMPLATES: Final[Mapping[str, str]]
558558

559559
def iri_to_uri(iri: str) -> str: ...
560560
def to_high_limit_path(path: PathLike[AnyStr]) -> str: ...
@@ -620,8 +620,8 @@ class Namespace(types.SimpleNamespace):
620620
@property
621621
def items_(self) -> dict[str, Any]: ...
622622

623-
MEDIA_EXTENSIONS: Namespace
624-
KNOWN_EXTENSIONS: tuple[str, ...]
623+
MEDIA_EXTENSIONS: Final[Namespace]
624+
KNOWN_EXTENSIONS: Final[tuple[str, ...]]
625625

626626
class _UnsafeExtensionError(Exception):
627627
ALLOWED_EXTENSIONS: frozenset[str]

stubs/yt-dlp/yt_dlp/version.pyi

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
__version__: str
2-
RELEASE_GIT_HEAD: str
3-
VARIANT: str
4-
UPDATE_HINT: str
5-
CHANNEL: str
6-
ORIGIN: str
1+
from typing import Final
2+
3+
__version__: Final[str]
4+
RELEASE_GIT_HEAD: Final[str]
5+
VARIANT: Final[str]
6+
UPDATE_HINT: Final[str]
7+
CHANNEL: Final[str]
8+
ORIGIN: Final[str]

0 commit comments

Comments
 (0)