mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-25 00:27:46 +01:00
Document Return Types of RequestData
Members (#4396)
This commit is contained in:
parent
af76a8485f
commit
a967dbe37a
1 changed files with 15 additions and 0 deletions
|
@ -55,6 +55,9 @@ class RequestData:
|
||||||
a single object of type :obj:`int`, :obj:`float`, :obj:`str` or :obj:`bool` or 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
|
(possibly nested) composition of lists, tuples and dictionaries, where each entry, key
|
||||||
and value is of one of the mentioned types.
|
and value is of one of the mentioned types.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dict[:obj:`str`, Union[:obj:`str`, :obj:`int`, List[any], Dict[any, any]]]
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
param.name: param.value # type: ignore[misc]
|
param.name: param.value # type: ignore[misc]
|
||||||
|
@ -71,6 +74,9 @@ class RequestData:
|
||||||
By default, this property uses the standard library's :func:`json.dumps`.
|
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
|
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.
|
:attr:`parameters` - note that string valued keys should not be JSON encoded.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dict[:obj:`str`, :obj:`str`]
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
param.name: param.json_value
|
param.name: param.json_value
|
||||||
|
@ -84,6 +90,9 @@ class RequestData:
|
||||||
Args:
|
Args:
|
||||||
encode_kwargs (Dict[:obj:`str`, any], optional): Additional keyword arguments to pass
|
encode_kwargs (Dict[:obj:`str`, any], optional): Additional keyword arguments to pass
|
||||||
along to :func:`urllib.parse.urlencode`.
|
along to :func:`urllib.parse.urlencode`.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`str`
|
||||||
"""
|
"""
|
||||||
if encode_kwargs:
|
if encode_kwargs:
|
||||||
return urlencode(self.json_parameters, **encode_kwargs)
|
return urlencode(self.json_parameters, **encode_kwargs)
|
||||||
|
@ -97,6 +106,9 @@ class RequestData:
|
||||||
url (:obj:`str`): The URL the parameters will be attached to.
|
url (:obj:`str`): The URL the parameters will be attached to.
|
||||||
encode_kwargs (Dict[:obj:`str`, any], optional): Additional keyword arguments to pass
|
encode_kwargs (Dict[:obj:`str`, any], optional): Additional keyword arguments to pass
|
||||||
along to :func:`urllib.parse.urlencode`.
|
along to :func:`urllib.parse.urlencode`.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`str`
|
||||||
"""
|
"""
|
||||||
url_parameters = self.url_encoded_parameters(encode_kwargs=encode_kwargs)
|
url_parameters = self.url_encoded_parameters(encode_kwargs=encode_kwargs)
|
||||||
return f"{url}?{url_parameters}"
|
return f"{url}?{url_parameters}"
|
||||||
|
@ -109,6 +121,9 @@ class RequestData:
|
||||||
By default, this property uses the standard library's :func:`json.dumps`.
|
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
|
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.
|
: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)
|
return json.dumps(self.json_parameters).encode(TextEncoding.UTF_8)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue