15
15
# You should have received a copy of the GNU Lesser General Public License
16
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
18
+ from typing import Any , Callable , Dict , Optional
18
19
from urllib .parse import urlparse
19
20
21
+ import requests
22
+
20
23
21
24
class _StdoutStream (object ):
22
- def __call__ (self , chunk ):
25
+ def __call__ (self , chunk ) -> None :
23
26
print (chunk )
24
27
25
28
26
- def response_content (response , streamed , action , chunk_size ):
29
+ def response_content (
30
+ response : requests .Response ,
31
+ streamed : bool ,
32
+ action : Optional [Callable ],
33
+ chunk_size : int ,
34
+ ):
27
35
if streamed is False :
28
36
return response .content
29
37
@@ -35,7 +43,7 @@ def response_content(response, streamed, action, chunk_size):
35
43
action (chunk )
36
44
37
45
38
- def copy_dict (dest , src ) :
46
+ def copy_dict (dest : Dict [ str , Any ], src : Dict [ str , Any ]) -> None :
39
47
for k , v in src .items ():
40
48
if isinstance (v , dict ):
41
49
# Transform dict values to new attributes. For example:
@@ -47,7 +55,7 @@ def copy_dict(dest, src):
47
55
dest [k ] = v
48
56
49
57
50
- def clean_str_id (id ) :
58
+ def clean_str_id (id : str ) -> str :
51
59
return id .replace ("/" , "%2F" ).replace ("#" , "%23" )
52
60
53
61
@@ -59,11 +67,11 @@ def sanitize_parameters(value):
59
67
return value
60
68
61
69
62
- def sanitized_url (url ) :
70
+ def sanitized_url (url : str ) -> str :
63
71
parsed = urlparse (url )
64
72
new_path = parsed .path .replace ("." , "%2E" )
65
73
return parsed ._replace (path = new_path ).geturl ()
66
74
67
75
68
- def remove_none_from_dict (data ) :
76
+ def remove_none_from_dict (data : Dict [ str , Any ]) -> Dict [ str , Any ] :
69
77
return {k : v for k , v in data .items () if v is not None }
0 commit comments