Skip to content

Commit bc81621

Browse files
committed
Refactor: Minor simplifications
1 parent 05640e2 commit bc81621

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

easybuild/tools/modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ def run_module(self, *args, **kwargs):
12891289
# keep track of current values of select env vars, so we can correct the adjusted values below
12901290
# Identical to `{key: os.environ.get(key, '').split(os.pathsep)[::-1] for key in LD_ENV_VAR_KEYS}`
12911291
# but Python 2 treats that as a local function and refused the `exec` below
1292-
prev_ld_values = dict([(key, os.environ.get(key, '').split(os.pathsep)[::-1]) for key in LD_ENV_VAR_KEYS])
1292+
prev_ld_values = {key: os.environ.get(key, '').split(os.pathsep)[::-1] for key in LD_ENV_VAR_KEYS}
12931293

12941294
# Change the environment
12951295
try:

easybuild/tools/options.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ def terminal_supports_colors(stream):
128128

129129
XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), ".config"))
130130
XDG_CONFIG_DIRS = os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(os.pathsep)
131-
DEFAULT_SYS_CFGFILES = [[f for f in sorted(glob.glob(os.path.join(d, 'easybuild.d', '*.cfg')))]
131+
DEFAULT_SYS_CFGFILES = [sorted(glob.glob(os.path.join(d, 'easybuild.d', '*.cfg')))
132132
for d in XDG_CONFIG_DIRS]
133133
DEFAULT_USER_CFGFILE = os.path.join(XDG_CONFIG_HOME, 'easybuild', 'config.cfg')
134134

135135
DEFAULT_LIST_PR_STATE = GITHUB_PR_STATE_OPEN
136136
DEFAULT_LIST_PR_ORDER = GITHUB_PR_ORDER_CREATED
137137
DEFAULT_LIST_PR_DIREC = GITHUB_PR_DIRECTION_DESC
138138

139-
RPATH_DEFAULT = False if get_os_type() == DARWIN else True
139+
RPATH_DEFAULT = get_os_type() != DARWIN
140140

141141
_log = fancylogger.getLogger('options', fname=False)
142142

@@ -1136,7 +1136,7 @@ def _postprocess_close_pr_reasons(self):
11361136
)
11371137

11381138
reasons = self.options.close_pr_reasons.split(',')
1139-
if any([reason not in VALID_CLOSE_PR_REASONS.keys() for reason in reasons]):
1139+
if any(reason not in VALID_CLOSE_PR_REASONS for reason in reasons):
11401140
raise EasyBuildError(
11411141
"Argument to --close-pr_reasons must be a comma separated list of valid reasons among %s",
11421142
VALID_CLOSE_PR_REASONS.keys(), exit_code=EasyBuildExit.OPTION_ERROR
@@ -1562,7 +1562,7 @@ def show_system_info(self):
15621562
"* software:",
15631563
" -> glibc version: %s" % system_info['glibc_version'],
15641564
" -> Python binary: %s" % sys.executable,
1565-
" -> Python version: %s" % sys.version.split(' ')[0],
1565+
" -> Python version: %s" % sys.version.split(' ', maxsplit=1)[0],
15661566
])
15671567

15681568
return '\n'.join(lines)
@@ -1750,7 +1750,7 @@ def check_included_multiple(included_easyblocks_from, source):
17501750
if options.include_easyblocks:
17511751
# check if you are including the same easyblock twice
17521752
included_paths = expand_glob_paths(options.include_easyblocks)
1753-
included_easyblocks = set([os.path.basename(eb) for eb in included_paths])
1753+
included_easyblocks = {os.path.basename(eb) for eb in included_paths}
17541754

17551755
if options.include_easyblocks_from_pr:
17561756
try:
@@ -1763,7 +1763,7 @@ def check_included_multiple(included_easyblocks_from, source):
17631763

17641764
for easyblock_pr in easyblock_prs:
17651765
easyblocks_from_pr = fetch_easyblocks_from_pr(easyblock_pr)
1766-
included_from_pr = set([os.path.basename(eb) for eb in easyblocks_from_pr])
1766+
included_from_pr = {os.path.basename(eb) for eb in easyblocks_from_pr}
17671767

17681768
if options.include_easyblocks:
17691769
check_included_multiple(included_from_pr, "PR #%s" % easyblock_pr)
@@ -1777,7 +1777,7 @@ def check_included_multiple(included_easyblocks_from, source):
17771777
easyblock_commit = options.include_easyblocks_from_commit
17781778
if easyblock_commit:
17791779
easyblocks_from_commit = fetch_easyblocks_from_commit(easyblock_commit)
1780-
included_from_commit = set([os.path.basename(eb) for eb in easyblocks_from_commit])
1780+
included_from_commit = {os.path.basename(eb) for eb in easyblocks_from_commit}
17811781

17821782
if options.include_easyblocks:
17831783
check_included_multiple(included_from_commit, "commit %s" % easyblock_commit)

test/framework/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5666,7 +5666,7 @@ def test_zip_logs(self):
56665666
logs = glob.glob(os.path.join(toy_eb_install_dir, 'easybuild-toy-0.0*log*'))
56675667
self.assertEqual(len(logs), 1, "Found exactly 1 log file in %s: %s" % (toy_eb_install_dir, logs))
56685668

5669-
zip_logs_arg = zip_logs.split('=')[-1]
5669+
zip_logs_arg = zip_logs.rsplit('=', maxsplit=1)[-1]
56705670
if zip_logs == '--zip-logs' or zip_logs_arg == 'gzip':
56715671
ext = 'log.gz'
56725672
elif zip_logs_arg == 'bzip2':

0 commit comments

Comments
 (0)