Skip to content

Commit

Permalink
Merge pull request #4431 from dynamic-entropy/patch-4430-noqa_W605
Browse files Browse the repository at this point in the history
Warnings: converted noqa W605 strings to raw strings Fix #4430
  • Loading branch information
bari12 committed Mar 26, 2021
2 parents 6b3f51a + aa4877f commit c5b9415
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions bin/rucio-auditor
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get_parser():
default=3,
type=int,
)
parser.epilog = textwrap.dedent('''
parser.epilog = textwrap.dedent(r"""
examples:
# Check all RSEs using only 1 subprocess
%(prog)s
Expand All @@ -198,7 +198,7 @@ def get_parser():
# Check all Tier 2 DATADISKs, except "BLUE_DATADISK" and "RED_DATADISK"
%(prog)s --rses "tier=1&type=DATADISK\(BLUE_DATADISK|RED_DATADISK)"
''') # NOQA: W605
""")
return parser


Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/common/doc/argparse/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def parser_navigate(parser_result, path, current_path=None):
if isinstance(path, str):
if path == '':
return parser_result
path = re.split('\s+', path) # NOQA: W605
path = re.split(r'\s+', path)
current_path = current_path or []
if len(path) == 0:
return parser_result
Expand Down
23 changes: 12 additions & 11 deletions lib/rucio/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,35 +218,35 @@ def all_oidc_req_claims_present(scope, audience, required_scope, required_audien
required_scope = ""
if not required_audience:
required_audience = ""
if (isinstance(scope, list) and isinstance(audience, list) and # NOQA: W504
isinstance(required_scope, list) and isinstance(required_audience, list)):
if (isinstance(scope, list) and isinstance(audience, list) # NOQA: W504
and isinstance(required_scope, list) and isinstance(required_audience, list)):
scope = [str(it) for it in scope]
audience = [str(it) for it in audience]
required_scope = [str(it) for it in required_scope]
required_audience = [str(it) for it in required_audience]
req_scope_present = all(elem in scope for elem in required_scope)
req_audience_present = all(elem in audience for elem in required_audience)
return req_scope_present and req_audience_present
elif (isinstance(scope, string_types) and isinstance(audience, string_types) and # NOQA: W504
isinstance(required_scope, string_types) and isinstance(required_audience, string_types)):
elif (isinstance(scope, string_types) and isinstance(audience, string_types) # NOQA: W504
and isinstance(required_scope, string_types) and isinstance(required_audience, string_types)):
scope = str(scope)
audience = str(audience)
required_scope = str(required_scope)
required_audience = str(required_audience)
req_scope_present = all(elem in scope.split(sepatator) for elem in required_scope.split(sepatator))
req_audience_present = all(elem in audience.split(sepatator) for elem in required_audience.split(sepatator))
return req_scope_present and req_audience_present
elif (isinstance(scope, list) and isinstance(audience, list) and # NOQA: W504
isinstance(required_scope, string_types) and isinstance(required_audience, string_types)):
elif (isinstance(scope, list) and isinstance(audience, list) # NOQA: W504
and isinstance(required_scope, string_types) and isinstance(required_audience, string_types)):
scope = [str(it) for it in scope]
audience = [str(it) for it in audience]
required_scope = str(required_scope)
required_audience = str(required_audience)
req_scope_present = all(elem in scope for elem in required_scope.split(sepatator))
req_audience_present = all(elem in audience for elem in required_audience.split(sepatator))
return req_scope_present and req_audience_present
elif (isinstance(scope, string_types) and isinstance(audience, string_types) and # NOQA: W504
isinstance(required_scope, list) and isinstance(required_audience, list)):
elif (isinstance(scope, string_types) and isinstance(audience, string_types) # NOQA: W504
and isinstance(required_scope, list) and isinstance(required_audience, list)):
scope = str(scope)
audience = str(audience)
required_scope = [str(it) for it in required_scope]
Expand Down Expand Up @@ -409,6 +409,7 @@ class APIEncoder(json.JSONEncoder):
""" Propretary JSONEconder subclass used by the json render function.
This is needed to address the encoding of special values.
"""

def default(self, obj): # pylint: disable=E0202
if isinstance(obj, datetime.datetime):
# convert any datetime to RFC 1123 format
Expand Down Expand Up @@ -662,9 +663,9 @@ def clean_surls(surls):
for surl in surls:
if surl.startswith('srm'):
surl = re.sub(':[0-9]+/', '/', surl)
surl = re.sub('/srm/managerv1\?SFN=', '', surl) # NOQA: W605
surl = re.sub('/srm/v2/server\?SFN=', '', surl) # NOQA: W605
surl = re.sub('/srm/managerv2\?SFN=', '', surl) # NOQA: W605
surl = re.sub(r'/srm/managerv1\?SFN=', '', surl)
surl = re.sub(r'/srm/v2/server\?SFN=', '', surl)
surl = re.sub(r'/srm/managerv2\?SFN=', '', surl)
if surl.startswith('https://storage.googleapis.com'):
surl = surl.split('?GoogleAccessId')[0]
if '?X-Amz' in surl:
Expand Down
4 changes: 2 additions & 2 deletions lib/rucio/core/did.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,11 +1416,11 @@ def list_dids(scope, filters, type='collection', ignore_case=False, limit=None,
continue
if session.bind.dialect.name == 'postgresql':
query = query.filter(getattr(models.DataIdentifier, k).
like(v.replace('*', '%').replace('_', '\_'), # NOQA: W605
like(v.replace('*', '%').replace('_', r'\_'),
escape='\\'))
else:
query = query.filter(getattr(models.DataIdentifier, k).
like(v.replace('*', '%').replace('_', '\_'), escape='\\')) # NOQA: W605
like(v.replace('*', '%').replace('_', r'\_'), escape='\\'))
elif k == 'created_before':
created_before = str_to_date(v)
query = query.filter(models.DataIdentifier.created_at <= created_before)
Expand Down
6 changes: 3 additions & 3 deletions lib/rucio/core/did_meta_plugins/did_column_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ def list_dids(self, scope, filters, type='collection', ignore_case=False, limit=
continue
if session.bind.dialect.name == 'postgresql':
query = query.filter(getattr(models.DataIdentifier, k).
like(v.replace('*', '%').replace('_', '\_'), # NOQA: W605
escape='\\'))
like(v.replace('*', '%').replace('_', r'\_'),
escape='\\'))
else:
query = query.filter(getattr(models.DataIdentifier, k).
like(v.replace('*', '%').replace('_', '\_'), escape='\\')) # NOQA: W605
like(v.replace('*', '%').replace('_', r'\_'), escape='\\'))
elif k == 'created_before':
created_before = str_to_date(v)
query = query.filter(models.DataIdentifier.created_at <= created_before)
Expand Down
3 changes: 2 additions & 1 deletion lib/rucio/daemons/hermes/hermes2.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class HermesListener(stomp.ConnectionListener):
'''
Hermes Listener
'''

def __init__(self, broker):
'''
__init__
Expand Down Expand Up @@ -340,7 +341,7 @@ def aggregate_to_influx(messages, bin_size, endpoint, prepend_str):
if transferred_at not in bins:
bins[transferred_at] = {}
src_rse, dest_rse, activity = payload['src-rse'], payload['dst-rse'], payload['activity']
activity = re.sub(' ', '\ ', activity) # noqa: W605
activity = re.sub(' ', r'\ ', activity)
key = 'transfer,activity=%s,src_rse=%s,dst_rse=%s' % (activity, src_rse, dest_rse)
if key not in bins[transferred_at]:
bins[transferred_at][key] = [0, 0, 0, 0]
Expand Down
8 changes: 4 additions & 4 deletions lib/rucio/tests/test_bin_rucio.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def test_upload_repeated_file(self):
print(out)
print(err)
# get the rule for the file
cmd = "rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1_name) # NOQA: W605
cmd = r"rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1_name)
print(self.marker + cmd)
exitcode, out, err = execute(cmd)
print(out, err)
Expand Down Expand Up @@ -825,7 +825,7 @@ def test_download_fails_badmd5(self):
exitcode, out, err = execute(cmd)
print(out, err)

report = 'Local\ checksum\:\ {0},\ Rucio\ checksum\:\ 0123456789abcdef0123456789abcdef'.format(file_md5) # NOQA: W605
report = r'Local\ checksum\:\ {0},\ Rucio\ checksum\:\ 0123456789abcdef0123456789abcdef'.format(file_md5)
print('searching', report, 'in', err)
assert re.search(report, err) is not None

Expand Down Expand Up @@ -1007,7 +1007,7 @@ def test_delete_rule(self):
print(err)
print(out)
# get the rules for the file
cmd = "rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:]) # NOQA: W605
cmd = r"rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:])
print(self.marker + cmd)
exitcode, out, err = execute(cmd)
print(out, err)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ def test_add_delete_add_file(self):
exitcode, out, err = execute(cmd)
print(out, err)
# get the rule for the file
cmd = "rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:]) # NOQA: W605
cmd = r"rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:])
print(self.marker + cmd)
exitcode, out, err = execute(cmd)
print(out, err)
Expand Down
2 changes: 1 addition & 1 deletion tools/generate_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run_git_command(cmd):
else:
GIT_VERSION_CMD = 'git describe --abbrev=4'
GIT_VERSION = run_git_command(GIT_VERSION_CMD).decode()
BRANCH_NICK_CMD = 'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "' # NOQA: W605
BRANCH_NICK_CMD = r'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "'
BRANCH_NICK = run_git_command(BRANCH_NICK_CMD).decode()
REVID_CMD = "git rev-parse HEAD"
REVID = run_git_command(REVID_CMD).decode()
Expand Down

0 comments on commit c5b9415

Please sign in to comment.