1515# You should have received a copy of the GNU Lesser General Public License
1616# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18+ from typing import Any ,Callable ,Dict ,Optional
1819from urllib .parse import urlparse
1920
21+ import requests
22+
2023
2124class _StdoutStream (object ):
22- def __call__ (self ,chunk ):
25+ def __call__ (self ,chunk )-> None :
2326print (chunk )
2427
2528
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+ ):
2735if streamed is False :
2836return response .content
2937
@@ -35,7 +43,7 @@ def response_content(response, streamed, action, chunk_size):
3543action (chunk )
3644
3745
38- def copy_dict (dest , src ) :
46+ def copy_dict (dest : Dict [ str , Any ], src : Dict [ str , Any ]) -> None :
3947for k ,v in src .items ():
4048if isinstance (v ,dict ):
4149# Transform dict values to new attributes. For example:
@@ -47,7 +55,7 @@ def copy_dict(dest, src):
4755dest [k ]= v
4856
4957
50- def clean_str_id (id ) :
58+ def clean_str_id (id : str ) -> str :
5159return id .replace ("/" ,"%2F" ).replace ("#" ,"%23" )
5260
5361
@@ -59,11 +67,11 @@ def sanitize_parameters(value):
5967return value
6068
6169
62- def sanitized_url (url ) :
70+ def sanitized_url (url : str ) -> str :
6371parsed = urlparse (url )
6472new_path = parsed .path .replace ("." ,"%2E" )
6573return parsed ._replace (path = new_path ).geturl ()
6674
6775
68- def remove_none_from_dict (data ) :
76+ def remove_none_from_dict (data : Dict [ str , Any ]) -> Dict [ str , Any ] :
6977return {k :v for k ,v in data .items ()if v is not None }