diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index 73182da7ac..1b28cba328 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -849,7 +849,7 @@ def check_deprecated(self, path): if depr_msgs: depr_msg = ', '.join(depr_msgs) - depr_maj_ver = int(str(VERSION).split('.')[0]) + 1 + depr_maj_ver = int(str(VERSION).split('.', maxsplit=1)[0]) + 1 depr_ver = '%s.0' % depr_maj_ver more_info_depr_ec = " (see also http://easybuild.readthedocs.org/en/latest/Deprecated-easyconfigs.html)" @@ -864,8 +864,8 @@ def validate(self, check_osdeps=True): - check license """ self.log.info("Validating easyconfig") - for attr in self.validations: - self._validate(attr, self.validations[attr]) + for attr, valid_values in self.validations.items(): + self._validate(attr, valid_values) if check_osdeps: self.log.info("Checking OS dependencies") @@ -1229,8 +1229,8 @@ def dump(self, fp, always_overwrite=True, backup=False, explicit_toolchains=Fals # templated values should be dumped unresolved with self.disable_templating(): # build dict of default values - default_values = {key: DEFAULT_CONFIG[key][0] for key in DEFAULT_CONFIG} - default_values.update({key: self.extra_options[key][0] for key in self.extra_options}) + default_values = {key: value[0] for key, value in DEFAULT_CONFIG.items()} + default_values.update({key: value[0] for key, value in self.extra_options.items()}) self.generate_template_values() templ_const = {quote_py_str(const[1]): const[0] for const in TEMPLATE_CONSTANTS} diff --git a/test/framework/easyconfig.py b/test/framework/easyconfig.py index 45e2852221..9801e467dd 100644 --- a/test/framework/easyconfig.py +++ b/test/framework/easyconfig.py @@ -2141,8 +2141,8 @@ def test_external_dependencies_templates(self): 'pyshortver': '3.6', 'pyver': '3.6.5', } - for key in expected_template_values: - self.assertEqual(ec.template_values[key], expected_template_values[key]) + for key, expected in expected_template_values.items(): + self.assertEqual(ec.template_values[key], expected) self.assertEqual(ec['versionsuffix'], '-Python-3.6.5-Perl-5.30') @@ -2218,8 +2218,8 @@ def test_quote_str(self): 'foo\\bar': '"foo\\bar"', } - for t in teststrings: - self.assertEqual(quote_str(t), teststrings[t]) + for t, expected in teststrings.items(): + self.assertEqual(quote_str(t), expected) # test escape_newline self.assertEqual(quote_str("foo\nbar", escape_newline=False), '"foo\nbar"') @@ -4873,8 +4873,8 @@ def test_get_cuda_cc_template_value(self): update_build_option('cuda_compute_capabilities', ['6.5', '7.0']) ec = EasyConfig(self.eb_file) - for key in cuda_template_values: - self.assertEqual(ec.get_cuda_cc_template_value(key), cuda_template_values[key]) + for key, expected in cuda_template_values.items(): + self.assertEqual(ec.get_cuda_cc_template_value(key), expected) update_build_option('cuda_compute_capabilities', None) ec = EasyConfig(self.eb_file) @@ -4886,8 +4886,8 @@ def test_get_cuda_cc_template_value(self): self.prep() ec = EasyConfig(self.eb_file) - for key in cuda_template_values: - self.assertEqual(ec.get_cuda_cc_template_value(key), cuda_template_values[key]) + for key, expected in cuda_template_values.items(): + self.assertEqual(ec.get_cuda_cc_template_value(key), expected) def test_count_files(self): """Tests for EasyConfig.count_files method."""