-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 stubs for m3u8 #12683
Open
DinhHuy2010
wants to merge
6
commits into
python:main
Choose a base branch
from
DinhHuy2010:m3u8-stubs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+623
−0
Open
add stubs for m3u8 #12683
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d6d5ea3
add stubs for m3u8
DinhHuy2010 33c5a78
fix stubs
DinhHuy2010 1400fba
Merge remote-tracking branch 'upstream/main' into m3u8-stubs
DinhHuy2010 3de849d
Merge branch 'python:main' into m3u8-stubs
DinhHuy2010 d336345
change __all__ to tuple type
DinhHuy2010 2f353ab
fix allowlist
DinhHuy2010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# type check only | ||
m3u8.httpclient.HTTPSHandler.__new__ | ||
# internal functions and attributes | ||
m3u8.M3U8.simple_attributes | ||
m3u8.model.M3U8.simple_attributes | ||
m3u8.model.denormalize_attribute | ||
m3u8.model.find_key | ||
m3u8.model.number_to_string | ||
m3u8.model.quoted | ||
m3u8.parser.cast_date_time | ||
m3u8.parser.format_date_time | ||
m3u8.parser.get_segment_custom_value | ||
m3u8.parser.normalize_attribute | ||
m3u8.parser.remove_quotes | ||
m3u8.parser.remove_quotes_parser | ||
m3u8.parser.save_segment_custom_value | ||
m3u8.parser.string_to_lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version = "6.0.*" | ||
upstream_repository = "https://github.com/globocom/m3u8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Callable, Mapping | ||
from typing import Any | ||
from typing_extensions import TypeAlias | ||
|
||
from m3u8.httpclient import _HTTPClientProtocol | ||
from m3u8.model import ( | ||
M3U8, | ||
ContentSteering, | ||
DateRange, | ||
DateRangeList, | ||
IFramePlaylist, | ||
ImagePlaylist, | ||
Key, | ||
Media, | ||
MediaList, | ||
PartialSegment, | ||
PartialSegmentList, | ||
PartInformation, | ||
Playlist, | ||
PlaylistList, | ||
PreloadHint, | ||
RenditionReport, | ||
RenditionReportList, | ||
Segment, | ||
SegmentList, | ||
ServerControl, | ||
Skip, | ||
Start, | ||
Tiles, | ||
) | ||
from m3u8.parser import ParseError, parse | ||
|
||
__all__ = ( | ||
"M3U8", | ||
"Segment", | ||
"SegmentList", | ||
"PartialSegment", | ||
"PartialSegmentList", | ||
"Key", | ||
"Playlist", | ||
"IFramePlaylist", | ||
"Media", | ||
"MediaList", | ||
"PlaylistList", | ||
"Start", | ||
"RenditionReport", | ||
"RenditionReportList", | ||
"ServerControl", | ||
"Skip", | ||
"PartInformation", | ||
"PreloadHint", | ||
"DateRange", | ||
"DateRangeList", | ||
"ContentSteering", | ||
"ImagePlaylist", | ||
"Tiles", | ||
"loads", | ||
"load", | ||
"parse", | ||
"ParseError", | ||
) | ||
|
||
_CustomTagsParser: TypeAlias = Callable[[str, int, dict[str, Any], dict[str, Any]], object] | ||
|
||
def loads(content: str, uri: str | None = None, custom_tags_parser: _CustomTagsParser | None = None) -> M3U8: ... | ||
def load( | ||
uri: str, | ||
timeout: Incomplete | None = None, | ||
headers: Mapping[str, Any] = {}, | ||
custom_tags_parser: _CustomTagsParser | None = None, | ||
http_client: _HTTPClientProtocol = ..., | ||
verify_ssl: bool = True, | ||
) -> M3U8: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import urllib.request | ||
from typing import Any, Protocol, type_check_only | ||
|
||
@type_check_only | ||
class _HTTPClientProtocol(Protocol): # noqa: Y046 | ||
def download( | ||
self, uri: str, timeout: float | None = None, headers: dict[str, Any] = {}, verify_ssl: bool = True | ||
) -> tuple[str, str]: ... | ||
|
||
class DefaultHTTPClient: | ||
proxies: dict[str, str] | None | ||
|
||
def __init__(self, proxies: dict[str, str] | None = None) -> None: ... | ||
def download( | ||
self, uri: str, timeout: float | None = None, headers: dict[str, Any] = {}, verify_ssl: bool = True | ||
) -> tuple[str, str]: ... | ||
|
||
class HTTPSHandler: | ||
def __new__(cls, verify_ssl: bool = True) -> urllib.request.HTTPSHandler: ... # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# mypy: disable-error-code="attr-defined" | ||
|
||
from abc import ABCMeta | ||
from collections.abc import Iterable | ||
from typing import Protocol, TypeVar | ||
|
||
_T = TypeVar("_T") | ||
|
||
class BasePathMixin(Protocol): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is not a protocol at runtime, it shouldn't be a protocol here either. |
||
uri: str | None | ||
@property | ||
def absolute_uri(self) -> str: ... | ||
@property | ||
def base_path(self) -> str: ... | ||
@base_path.setter | ||
def base_path(self, newbase_path: str) -> None: ... | ||
def get_path_from_uri(self) -> str: ... | ||
|
||
class GroupedBasePathMixin(Iterable[_T], metaclass=ABCMeta): | ||
@property | ||
def base_uri(self) -> str: ... | ||
@base_uri.setter | ||
def base_uri(self, __new_url: str, /) -> None: ... | ||
@property | ||
def base_path(self) -> str: ... | ||
@base_path.setter | ||
def base_path(self, __new_url: str, /) -> None: ... |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary. In general, we prefer
# type: ignore[attr-defined]
on the lines that this actually affects.