1212import xml
1313import zipfile
1414from pathlib import Path
15- from typing import Dict , Tuple , Union
15+ from typing import Dict , Tuple , Union , cast
1616
1717import minio
1818import requests
@@ -71,7 +71,7 @@ def resolve_env_proxies(url: str) -> str | None:
7171
7272
7373def _create_url_from_endpoint (endpoint : str ) -> str :
74- url = config ._config . server
74+ url = cast ( str , config .server )
7575 if not url .endswith ("/" ):
7676 url += "/"
7777 url += endpoint
@@ -172,7 +172,7 @@ def _download_minio_file(
172172 bucket_name = bucket ,
173173 object_name = object_name ,
174174 file_path = str (destination ),
175- progress = ProgressBar () if config ._config . show_progress else None ,
175+ progress = ProgressBar () if config .show_progress else None ,
176176 request_headers = _HEADERS ,
177177 )
178178 if destination .is_file () and destination .suffix == ".zip" :
@@ -301,7 +301,8 @@ def _file_id_to_url(file_id: int, filename: str | None = None) -> str:
301301 Presents the URL how to download a given file id
302302 filename is optional
303303 """
304- openml_url = config ._config .server .split ("/api/" )
304+ openml_server = cast (str , config .server )
305+ openml_url = openml_server .split ("/api/" )
305306 url = openml_url [0 ] + f"/data/download/{ file_id !s} "
306307 if filename is not None :
307308 url += "/" + filename
@@ -317,7 +318,7 @@ def _read_url_files(
317318 and sending file_elements as files
318319 """
319320 data = {} if data is None else data
320- data ["api_key" ] = config ._config . apikey
321+ data ["api_key" ] = config .apikey
321322 if file_elements is None :
322323 file_elements = {}
323324 # Using requests.post sets header 'Accept-encoding' automatically to
@@ -337,8 +338,8 @@ def __read_url(
337338 md5_checksum : str | None = None ,
338339) -> requests .Response :
339340 data = {} if data is None else data
340- if config ._config . apikey :
341- data ["api_key" ] = config ._config . apikey
341+ if config .apikey :
342+ data ["api_key" ] = config .apikey
342343 return _send_request (
343344 request_method = request_method ,
344345 url = url ,
@@ -363,10 +364,10 @@ def _send_request( # noqa: C901, PLR0912
363364 files : FILE_ELEMENTS_TYPE | None = None ,
364365 md5_checksum : str | None = None ,
365366) -> requests .Response :
366- n_retries = max (1 , config ._config . connection_n_retries )
367+ n_retries = max (1 , config .connection_n_retries )
367368
368369 response : requests .Response | None = None
369- delay_method = _human_delay if config ._config . retry_policy == "human" else _robot_delay
370+ delay_method = _human_delay if config .retry_policy == "human" else _robot_delay
370371
371372 # Error to raise in case of retrying too often. Will be set to the last observed exception.
372373 retry_raise_e : Exception | None = None
0 commit comments