Skip to content

Commit

Permalink
Testing: Add type annotations to utils.py; rucio#6588
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio committed Mar 25, 2024
1 parent bed3f05 commit 06e56a8
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 101 deletions.
22 changes: 16 additions & 6 deletions lib/rucio/client/baseclient.py
Expand Up @@ -93,7 +93,6 @@ def __init__(self, rucio_host=None, auth_host=None, account=None, ca_cert=None,
:param logger: Logger object to use. If None, use the default LOG created by the module
"""

self.host = rucio_host
self.list_hosts = []
self.auth_host = auth_host
self.logger = logger or LOG
Expand All @@ -104,9 +103,17 @@ def __init__(self, rucio_host=None, auth_host=None, account=None, ca_cert=None,
if self.script_id == '': # Python interpreter used
self.script_id = 'python'
try:
if self.host is None:
if rucio_host is not None:
self.host = rucio_host
else:
self.host = config_get('client', 'rucio_host')
if self.auth_host is None:
except (NoOptionError, NoSectionError) as error:
raise MissingClientParameter('Section client and Option \'%s\' cannot be found in config file' % error.args[0])

try:
if auth_host is not None:
self.auth_host = auth_host
else:
self.auth_host = config_get('client', 'auth_host')
except (NoOptionError, NoSectionError) as error:
raise MissingClientParameter('Section client and Option \'%s\' cannot be found in config file' % error.args[0])
Expand Down Expand Up @@ -295,9 +302,12 @@ def _get_exception(self, headers, status_code=None, data=None):
:return: A rucio exception class and an error string.
"""
try:
data = parse_response(data)
except ValueError:
if data is not None:
try:
data = parse_response(data)
except ValueError:
data = {}
else:
data = {}

exc_cls = 'RucioException'
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/client/downloadclient.py
Expand Up @@ -1181,7 +1181,7 @@ def _resolve_and_merge_input_items(self, input_items, sort=None):
resolve_parents=True,
nrandom=nrandom,
metalink=True)
file_items = parse_replicas_from_string(metalink_str)
file_items = parse_replicas_from_string(metalink_str) # type: ignore
for file in file_items:
if impl:
file['impl'] = impl
Expand Down
8 changes: 8 additions & 0 deletions lib/rucio/common/types.py
Expand Up @@ -178,3 +178,11 @@ class RuleDict(TypedDict):
class DIDDict(TypedDict):
name: str
scope: InternalScope


class IPDict(TypedDict):
ip: str
fqdn: str
site: str
latitude: Optional[float]
longitude: Optional[float]

0 comments on commit 06e56a8

Please sign in to comment.