Skip to content

Commit

Permalink
Merge pull request easybuilders#4411 from Flamefire/to_str
Browse files Browse the repository at this point in the history
Remove superflous string formatting
  • Loading branch information
boegel authored Jan 3, 2024
2 parents 00a3f52 + 1319196 commit d7cd5e3
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions easybuild/base/generaloption.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def set_columns(cols=None):
pass

if cols is not None:
os.environ['COLUMNS'] = "%s" % cols
os.environ['COLUMNS'] = str(cols)


def what_str_list_tuple(name):
Expand Down Expand Up @@ -822,8 +822,8 @@ def get_env_options(self):
self.environment_arguments.append("%s=%s" % (lo, val))
else:
# interpretation of values: 0/no/false means: don't set it
if ("%s" % val).lower() not in ("0", "no", "false",):
self.environment_arguments.append("%s" % lo)
if str(val).lower() not in ("0", "no", "false",):
self.environment_arguments.append(str(lo))
else:
self.log.debug("Environment variable %s is not set" % env_opt_name)

Expand Down Expand Up @@ -1189,7 +1189,7 @@ def add_group_parser(self, opt_dict, description, prefix=None, otherdefaults=Non
for extra_detail in details[4:]:
if isinstance(extra_detail, (list, tuple,)):
# choices
nameds['choices'] = ["%s" % x for x in extra_detail] # force to strings
nameds['choices'] = [str(x) for x in extra_detail] # force to strings
hlp += ' (choices: %s)' % ', '.join(nameds['choices'])
elif isinstance(extra_detail, string_type) and len(extra_detail) == 1:
args.insert(0, "-%s" % extra_detail)
Expand Down
2 changes: 1 addition & 1 deletion easybuild/framework/easyconfig/format/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def parse(self, configobj):
for key, value in self.supported.items():
if key not in self.VERSION_OPERATOR_VALUE_TYPES:
raise EasyBuildError('Unsupported key %s in %s section', key, self.SECTION_MARKER_SUPPORTED)
self.sections['%s' % key] = value
self.sections[key] = value

for key, supported_key, fn_name in [('version', 'versions', 'get_version_str'),
('toolchain', 'toolchains', 'as_dict')]:
Expand Down
2 changes: 1 addition & 1 deletion easybuild/framework/easyconfig/tweak.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def __repr__(self):
newval = "%s + %s" % (fval, res.group('val'))
_log.debug("Prepending %s to %s" % (fval, key))
else:
newval = "%s" % fval
newval = str(fval)
_log.debug("Overwriting %s with %s" % (key, fval))
ectxt = regexp.sub("%s = %s" % (res.group('key'), newval), ectxt)
_log.info("Tweaked %s list to '%s'" % (key, newval))
Expand Down
6 changes: 3 additions & 3 deletions easybuild/tools/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def avail_easyconfig_licenses_md():
lics = sorted(EASYCONFIG_LICENSES_DICT.items())
table_values = [
["``%s``" % lic().name for _, lic in lics],
["%s" % lic().description for _, lic in lics],
[lic().description or '' for _, lic in lics],
["``%s``" % lic().version for _, lic in lics],
]

Expand Down Expand Up @@ -1266,7 +1266,7 @@ def avail_toolchain_opts_md(name, tc_dict):
tc_items = sorted(tc_dict.items())
table_values = [
['``%s``' % val[0] for val in tc_items],
['%s' % val[1][1] for val in tc_items],
[val[1][1] for val in tc_items],
['``%s``' % val[1][0] for val in tc_items],
]

Expand All @@ -1284,7 +1284,7 @@ def avail_toolchain_opts_rst(name, tc_dict):
tc_items = sorted(tc_dict.items())
table_values = [
['``%s``' % val[0] for val in tc_items],
['%s' % val[1][1] for val in tc_items],
[val[1][1] for val in tc_items],
['``%s``' % val[1][0] for val in tc_items],
]

Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,7 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
clone_cmd.append('%s/%s.git' % (url, repo_name))

if clone_into:
clone_cmd.append('%s' % clone_into)
clone_cmd.append(clone_into)

tmpdir = tempfile.mkdtemp()
cwd = change_dir(tmpdir)
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ def get_description(self, conflict=True):
extensions_list = self._generate_extensions_list()

if extensions_list:
extensions_stmt = 'extensions("%s")' % ','.join(['%s' % x for x in extensions_list])
extensions_stmt = 'extensions("%s")' % ','.join([str(x) for x in extensions_list])
# put this behind a Lmod version check as 'extensions' is only (well) supported since Lmod 8.2.8,
# see https://lmod.readthedocs.io/en/latest/330_extensions.html#module-extensions and
# https://github.com/TACC/Lmod/issues/428
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nrs=None, gist_
])
test_report.extend([
"#### Test result",
"%s" % msg,
msg,
"",
])

Expand Down
8 changes: 4 additions & 4 deletions test/framework/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_descr(self):
'',
'Description',
'===========',
"%s" % descr,
descr,
'',
'',
"More information",
Expand All @@ -107,7 +107,7 @@ def test_descr(self):
'',
'Description',
'===========',
"%s" % descr,
descr,
'',
'',
"More information",
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_descr(self):
'',
'Description',
'===========',
"%s" % descr,
descr,
'',
'',
"More information",
Expand All @@ -161,7 +161,7 @@ def test_descr(self):
'',
'Description',
'===========',
"%s" % descr,
descr,
'',
'',
"More information",
Expand Down
2 changes: 1 addition & 1 deletion test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ def test_ignore_osdeps(self):
self.assertTrue(regex.search(outtxt), "OS dependencies are checked, outtxt: %s" % outtxt)
msg = "One or more OS dependencies were not found: "
msg += r"\[\('nosuchosdependency',\), \('nosuchdep_option1', 'nosuchdep_option2'\)\]"
regex = re.compile(r'%s' % msg, re.M)
regex = re.compile(msg, re.M)
self.assertTrue(regex.search(outtxt), "OS dependencies are honored, outtxt: %s" % outtxt)

# check whether OS dependencies are effectively ignored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ def is_short_modname_for(self, modname, name):
"""
Determine whether the specified (short) module name is a module for software with the specified name.
"""
return modname.find('%s' % name) != -1
return modname.find(name) != -1
4 changes: 2 additions & 2 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ def test_toy_module_fulltxt(self):
mod_txt_regex_pattern = '\n'.join([
r'help\(\[==\[',
r'',
r'%s' % help_txt,
help_txt,
r'\]==\]\)',
r'',
r'whatis\(\[==\[Description: Toy C program, 100% toy.\]==\]\)',
Expand Down Expand Up @@ -1528,7 +1528,7 @@ def test_toy_module_fulltxt(self):
r'proc ModulesHelp { } {',
r' puts stderr {',
r'',
r'%s' % help_txt,
help_txt,
r' }',
r'}',
r'',
Expand Down

0 comments on commit d7cd5e3

Please sign in to comment.