From a967dbe37a44925fedd56202bdc0e8e62b5e14a8 Mon Sep 17 00:00:00 2001 From: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:41:39 +0200 Subject: [PATCH] Document Return Types of `RequestData` Members (#4396) --- telegram/request/_requestdata.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/telegram/request/_requestdata.py b/telegram/request/_requestdata.py index 1b5b5446d..82d1e3d2c 100644 --- a/telegram/request/_requestdata.py +++ b/telegram/request/_requestdata.py @@ -55,6 +55,9 @@ class RequestData: 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] @@ -71,6 +74,9 @@ class RequestData: 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 @@ -84,6 +90,9 @@ class RequestData: 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) @@ -97,6 +106,9 @@ class RequestData: 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}" @@ -109,6 +121,9 @@ class RequestData: 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)