Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easybuild/base/frozendict.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, *args, **kwargs):

# handle unknown keys: either ignore them or raise an exception
tmpdict = dict(*args, **kwargs)
unknown_keys = [key for key in tmpdict.keys() if key not in self.KNOWN_KEYS]
unknown_keys = [key for key in tmpdict if key not in self.KNOWN_KEYS]
if unknown_keys:
if ignore_unknown_keys:
for key in unknown_keys:
Expand Down
2 changes: 1 addition & 1 deletion easybuild/base/generaloption.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def _make_debug_options(self):

def _set_default_loglevel(self):
"""Set the default loglevel if no logging options are set"""
loglevel_set = sum([getattr(self.options, name, False) for name in self._logopts.keys()])
loglevel_set = sum([getattr(self.options, name, False) for name in self._logopts])
if not loglevel_set and self.DEFAULT_LOGLEVEL is not None:
setLogLevel(self.DEFAULT_LOGLEVEL)

Expand Down
2 changes: 1 addition & 1 deletion easybuild/base/optcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __call__(self, **kwargs):
if self.CALL_ARGS_OPTIONAL is not None:
all_args.extend(self.CALL_ARGS_OPTIONAL)

for arg in kwargs.keys():
for arg in kwargs:
if arg not in all_args:
# remove it
kwargs.pop(arg)
Expand Down
6 changes: 3 additions & 3 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,11 +2203,11 @@ def resolve_template(value, tmpl_dict, expect_resolved=True):
orig_value = value
# map old templates to new values for alternative and deprecated templates
alt_map = {old_tmpl: tmpl_dict[new_tmpl] for (old_tmpl, new_tmpl) in
ALTERNATIVE_EASYCONFIG_TEMPLATES.items() if new_tmpl in tmpl_dict.keys()}
ALTERNATIVE_EASYCONFIG_TEMPLATES.items() if new_tmpl in tmpl_dict}
alt_map2 = {new_tmpl: tmpl_dict[old_tmpl] for (old_tmpl, new_tmpl) in
ALTERNATIVE_EASYCONFIG_TEMPLATES.items() if old_tmpl in tmpl_dict.keys()}
ALTERNATIVE_EASYCONFIG_TEMPLATES.items() if old_tmpl in tmpl_dict}
depr_map = {old_tmpl: tmpl_dict[new_tmpl] for (old_tmpl, (new_tmpl, ver)) in
DEPRECATED_EASYCONFIG_TEMPLATES.items() if new_tmpl in tmpl_dict.keys()}
DEPRECATED_EASYCONFIG_TEMPLATES.items() if new_tmpl in tmpl_dict}

# try templating with alternative and deprecated templates included
value = value % {**tmpl_dict, **alt_map, **alt_map2, **depr_map}
Expand Down
26 changes: 10 additions & 16 deletions easybuild/framework/easyconfig/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import sys
import tempfile
from collections import OrderedDict
from typing import List

from easybuild.base import fancylogger
from easybuild.framework.easyconfig import EASYCONFIGS_PKG_SUBDIR
Expand All @@ -60,7 +61,7 @@
from easybuild.tools.environment import restore_env
from easybuild.tools.filetools import EASYBLOCK_CLASS_PREFIX, get_cwd, find_easyconfigs, is_patch_file
from easybuild.tools.filetools import locate_files, read_file, resolve_path, which, write_file
from easybuild.tools.github import GITHUB_EASYCONFIGS_REPO
from easybuild.tools.github import GITHUB_EASYCONFIGS_REPO, CategorizedPaths
from easybuild.tools.github import det_pr_labels, det_pr_title, download_repo, fetch_easyconfigs_from_commit
from easybuild.tools.github import fetch_easyconfigs_from_pr, fetch_pr_data
from easybuild.tools.github import fetch_files_from_commit, fetch_files_from_pr
Expand Down Expand Up @@ -617,37 +618,30 @@ def dump_env_script(easyconfigs):
dump_env_easyblock(app, orig_env=orig_env, ec_path=ec.path, script_path=script_path)


def categorize_files_by_type(paths):
def categorize_files_by_type(paths: List[str]) -> CategorizedPaths:
"""
Splits list of filepaths into a 4 separate lists: easyconfigs, files to delete, patch files and
files with extension .py
"""
res = {
'easyconfigs': [],
'files_to_delete': [],
'patch_files': [],
'py_files': [],
}
res = CategorizedPaths([], [], [], [])

for path in paths:
if path.startswith(':'):
res['files_to_delete'].append(path[1:])
res.files_to_delete.append(path[1:])
elif path.endswith('.py'):
res['py_files'].append(path)
res.py_files.append(path)
# file must exist in order to check whether it's a patch file
elif os.path.isfile(path) and is_patch_file(path):
res['patch_files'].append(path)
res.patch_files.append(path)
elif path.endswith('.patch'):
if not os.path.exists(path):
raise EasyBuildError('File %s does not exist, did you mistype the path?', path)
elif not os.path.isfile(path):
if not os.path.isfile(path):
raise EasyBuildError('File %s is expected to be a regular file, but is a folder instead', path)
else:
raise EasyBuildError('%s is not detected as a valid patch file. Please verify its contents!',
path)
raise EasyBuildError('%s is not detected as a valid patch file. Please verify its contents!', path)
else:
# anything else is considered to be an easyconfig file
res['easyconfigs'].append(path)
res.easyconfigs.append(path)

return res

Expand Down
4 changes: 2 additions & 2 deletions easybuild/framework/easyconfig/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def check_key_types(val, allowed_types):
"""Check whether type of keys for specific dict value are as expected."""
if isinstance(val, dict):
res = True
for key in val.keys():
for key in val:
res &= any(is_value_of_type(key, t) for t in allowed_types)
else:
_log.debug("Specified value %s (type: %s) is not a dict, so key types check failed", val, type(val))
Expand All @@ -115,7 +115,7 @@ def check_key_types(val, allowed_types):
def check_known_keys(val, allowed_keys):
"""Check whether all keys for specified dict value are known keys."""
if isinstance(val, dict):
res = all(key in allowed_keys for key in val.keys())
res = all(key in allowed_keys for key in val)
else:
_log.debug("Specified value %s (type: %s) is not a dict, so known keys check failed", val, type(val))
res = False
Expand Down
2 changes: 1 addition & 1 deletion easybuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def process_eb_args(eb_args, eb_go, cfg_settings, modtool, testing, init_session
no_ec_opts = [options.aggregate_regtest, options.regtest, any_pr_option_set, search_query]

# determine paths to easyconfigs
determined_paths = det_easyconfig_paths(categorized_paths['easyconfigs'])
determined_paths = det_easyconfig_paths(categorized_paths.easyconfigs)

# only copy easyconfigs here if we're not using --try-* (that's handled below)
copy_ec = options.copy_ec and not tweaked_ecs_paths
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/containers/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def resolve_template_data(self):

def validate(self):
"""Perform validation of specified container configuration."""
if self.container_config not in DOCKER_OS_INSTALL_DEPS_TMPLS.keys():
if self.container_config not in DOCKER_OS_INSTALL_DEPS_TMPLS:
raise EasyBuildError("Unsupported container config '%s'" % self.container_config)
super().validate()

Expand Down
14 changes: 7 additions & 7 deletions easybuild/tools/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def list_software_md(software, detailed=True):
]

# links to per-letter tables
key_letters = nub(sorted(k[0].lower() for k in software.keys()))
key_letters = nub(sorted(k[0].lower() for k in software))
letter_links = ' - '.join(['[' + x + '](#' + x + ')' for x in ascii_lowercase if x in key_letters])
lines.extend([letter_links, ''])

Expand Down Expand Up @@ -922,7 +922,7 @@ def list_software_md(software, detailed=True):
return '\n'.join(lines)


def list_software_rst(software, detailed=False):
def list_software_rst(software: dict, detailed=False):
"""
Return overview of supported software in RST format

Expand All @@ -942,7 +942,7 @@ def list_software_rst(software, detailed=False):

# links to per-letter tables
letter_refs = ''
key_letters = nub(sorted(k[0].lower() for k in software.keys()))
key_letters = nub(sorted(k[0].lower() for k in software))
for letter in ascii_lowercase:
if letter in key_letters:
if letter_refs:
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def list_software_txt(software, detailed=False):
return '\n'.join(lines)


def list_software_json(software, detailed=False):
def list_software_json(software: dict, detailed=False):
"""
Return overview of supported software in json

Expand Down Expand Up @@ -1320,11 +1320,11 @@ def avail_toolchain_opts_json(name, tc_dict):
raise NotImplementedError("JSON output not implemented yet for --avail-toolchain-opts")


def avail_toolchain_opts_txt(name, tc_dict):
def avail_toolchain_opts_txt(name, tc_dict: dict):
""" Returns overview of toolchain options in txt format """
doc = ["Available options for %s toolchain:" % name]
for opt_name in sorted(tc_dict.keys()):
doc.append("%s%s: %s (default: %s)" % (INDENT_4SPACES, opt_name, tc_dict[opt_name][1], tc_dict[opt_name][0]))
for opt_name, value in sorted(tc_dict.items()):
doc.append("%s%s: %s (default: %s)" % (INDENT_4SPACES, opt_name, value[1], value[0]))

return '\n'.join(doc)

Expand Down
6 changes: 3 additions & 3 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def parse_http_header_fields_urlpat(arg, urlpat=None, header=None, urlpat_header
argline = header.strip() + ':' + argline

if urlpat is not None:
if urlpat in urlpat_headers.keys():
if urlpat in urlpat_headers:
urlpat_headers[urlpat].append(argline) # add headers to the list
else:
urlpat_headers[urlpat] = [argline] # new list headers for this urlpat
Expand Down Expand Up @@ -1618,9 +1618,9 @@ def create_patch_info(patch_spec):
patch_info = {'name': patch_spec}
elif isinstance(patch_spec, dict):
patch_info = {}
for key in patch_spec.keys():
for key, value in patch_spec.items():
if key in valid_keys:
patch_info[key] = patch_spec[key]
patch_info[key] = value
else:
raise EasyBuildError(
"Wrong patch spec '%s', use of unknown key %s in dict (valid keys are %s)",
Expand Down
Loading
Loading