Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Document Return Types ofRequestData Members#4396

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 1 commit intomasterfromrequest-data-types
Aug 2, 2024
Merged
Changes fromall 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
15 changes: 15 additions & 0 deletionstelegram/request/_requestdata.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,9 @@ def parameters(self) -> Dict[str, Union[str, int, List[Any], Dict[Any, Any]]]:
a single object of type :obj:`int`, :obj:`float`, :obj:`str` or :obj:`bool` or any
(possibly nested) composition of lists, tuples and dictionaries, where each entry, key
and value is of one of the mentioned types.

Returns:
Dict[:obj:`str`, Union[:obj:`str`, :obj:`int`, List[any], Dict[any, any]]]
"""
return {
param.name: param.value # type: ignore[misc]
Expand All@@ -71,6 +74,9 @@ def json_parameters(self) -> Dict[str, str]:
By default, this property uses the standard library's :func:`json.dumps`.
To use a custom library for JSON encoding, you can directly encode the keys of
:attr:`parameters` - note that string valued keys should not be JSON encoded.

Returns:
Dict[:obj:`str`, :obj:`str`]
"""
return {
param.name: param.json_value
Expand All@@ -84,6 +90,9 @@ def url_encoded_parameters(self, encode_kwargs: Optional[Dict[str, Any]] = None)
Args:
encode_kwargs (Dict[:obj:`str`, any], optional): Additional keyword arguments to pass
along to :func:`urllib.parse.urlencode`.

Returns:
:obj:`str`
"""
if encode_kwargs:
return urlencode(self.json_parameters, **encode_kwargs)
Expand All@@ -97,6 +106,9 @@ def parametrized_url(self, url: str, encode_kwargs: Optional[Dict[str, Any]] = N
url (:obj:`str`): The URL the parameters will be attached to.
encode_kwargs (Dict[:obj:`str`, any], optional): Additional keyword arguments to pass
along to :func:`urllib.parse.urlencode`.

Returns:
:obj:`str`
"""
url_parameters = self.url_encoded_parameters(encode_kwargs=encode_kwargs)
return f"{url}?{url_parameters}"
Expand All@@ -109,6 +121,9 @@ def json_payload(self) -> bytes:
By default, this property uses the standard library's :func:`json.dumps`.
To use a custom library for JSON encoding, you can directly encode the keys of
:attr:`parameters` - note that string valued keys should not be JSON encoded.

Returns:
:obj:`bytes`
"""
return json.dumps(self.json_parameters).encode(TextEncoding.UTF_8)

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp