Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Add type hints to utils.py and FilterEngine, refactoring code where needed #6604

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 16 additions & 7 deletions lib/rucio/client/baseclient.py
Expand Up @@ -107,8 +107,6 @@ def __init__(self,
:param logger: Logger object to use. If None, use the default LOG created by the module
"""

self.host = rucio_host
self.auth_host = auth_host
self.logger = logger
self.session = Session()
self.user_agent = "%s/%s" % (user_agent, version.version_string()) # e.g. "rucio-clients/0.2.13"
Expand All @@ -117,9 +115,17 @@ def __init__(self,
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 @@ -318,9 +324,12 @@ def _get_exception(self, headers: dict[str, str], status_code: Optional[int] = N

: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 @@ -1182,7 +1182,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 @@ -191,3 +191,11 @@ class HopDict(TypedDict):
dest_rse_id: str
dest_scheme: "SUPPORTED_PROTOCOLS_LITERAL"
dest_scheme_priority: int


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