diff --git a/splunklib/data.py b/splunklib/data.py index 32fbb522..34f3ffac 100644 --- a/splunklib/data.py +++ b/splunklib/data.py @@ -97,7 +97,7 @@ def load(text, match=None): def load_attrs(element): if not hasattrs(element): return None attrs = record() - for key, value in list(element.attrib.items()): + for key, value in element.attrib.items(): attrs[key] = value return attrs @@ -126,7 +126,7 @@ def load_elem(element, nametable=None): return name, attrs # Both attrs & value are complex, so merge the two dicts, resolving collisions. collision_keys = [] - for key, val in list(attrs.items()): + for key, val in attrs.items(): if key in value and key in collision_keys: value[key].append(val) elif key in value and key not in collision_keys: @@ -242,7 +242,7 @@ def __getitem__(self, key): return dict.__getitem__(self, key) key += self.sep result = record() - for k, v in list(self.items()): + for k, v in self.items(): if not k.startswith(key): continue suffix = k[len(key):] diff --git a/splunklib/searchcommands/decorators.py b/splunklib/searchcommands/decorators.py index b475d26e..1393d789 100644 --- a/splunklib/searchcommands/decorators.py +++ b/splunklib/searchcommands/decorators.py @@ -416,21 +416,21 @@ def __init__(self, command): OrderedDict.__init__(self, ((option.name, item_class(command, option)) for (name, option) in definitions)) def __repr__(self): - text = 'Option.View([' + ','.join([repr(item) for item in list(self.values())]) + '])' + text = 'Option.View([' + ','.join([repr(item) for item in self.values()]) + '])' return text def __str__(self): - text = ' '.join([str(item) for item in list(self.values()) if item.is_set]) + text = ' '.join([str(item) for item in self.values() if item.is_set]) return text # region Methods def get_missing(self): - missing = [item.name for item in list(self.values()) if item.is_required and not item.is_set] + missing = [item.name for item in self.values() if item.is_required and not item.is_set] return missing if len(missing) > 0 else None def reset(self): - for value in list(self.values()): + for value in self.values(): value.reset() # endregion diff --git a/tests/searchcommands/test_decorators.py b/tests/searchcommands/test_decorators.py index be9c3d3c..3cc571dd 100755 --- a/tests/searchcommands/test_decorators.py +++ b/tests/searchcommands/test_decorators.py @@ -353,9 +353,9 @@ def test_option(self): options.reset() missing = options.get_missing() - self.assertListEqual(missing, [option.name for option in list(options.values()) if option.is_required]) - self.assertListEqual(presets, [str(option) for option in list(options.values()) if option.value is not None]) - self.assertListEqual(presets, [str(option) for option in list(options.values()) if str(option) != option.name + '=None']) + self.assertListEqual(missing, [option.name for option in options.values() if option.is_required]) + self.assertListEqual(presets, [str(option) for option in options.values() if option.value is not None]) + self.assertListEqual(presets, [str(option) for option in options.values() if str(option) != option.name + '=None']) test_option_values = { validators.Boolean: ('0', 'non-boolean value'), @@ -372,7 +372,7 @@ def test_option(self): validators.RegularExpression: ('\\s+', '(poorly formed regular expression'), validators.Set: ('bar', 'non-existent set entry')} - for option in list(options.values()): + for option in options.values(): validator = option.validator if validator is None: @@ -431,9 +431,9 @@ def test_option(self): self.maxDiff = None tuplewrap = lambda x: x if isinstance(x, tuple) else (x,) - invert = lambda x: {v: k for k, v in list(x.items())} + invert = lambda x: {v: k for k, v in x.items()} - for x in list(command.options.values()): + for x in command.options.values(): # isinstance doesn't work for some reason if type(x.value).__name__ == 'Code': self.assertEqual(expected[x.name], x.value.source) diff --git a/tests/searchcommands/test_internals_v1.py b/tests/searchcommands/test_internals_v1.py index e408271b..bea5c618 100755 --- a/tests/searchcommands/test_internals_v1.py +++ b/tests/searchcommands/test_internals_v1.py @@ -53,7 +53,7 @@ def fix_up(cls, command_class): pass command = TestCommandLineParserCommand() CommandLineParser.parse(command, options) - for option in list(command.options.values()): + for option in command.options.values(): if option.name in ['logging_configuration', 'logging_level', 'record', 'show_configuration']: self.assertFalse(option.is_set) continue @@ -70,7 +70,7 @@ def fix_up(cls, command_class): pass command = TestCommandLineParserCommand() CommandLineParser.parse(command, options + fieldnames) - for option in list(command.options.values()): + for option in command.options.values(): if option.name in ['logging_configuration', 'logging_level', 'record', 'show_configuration']: self.assertFalse(option.is_set) continue @@ -85,7 +85,7 @@ def fix_up(cls, command_class): pass command = TestCommandLineParserCommand() CommandLineParser.parse(command, ['required_option=true'] + fieldnames) - for option in list(command.options.values()): + for option in command.options.values(): if option.name in ['unnecessary_option', 'logging_configuration', 'logging_level', 'record', 'show_configuration']: self.assertFalse(option.is_set) diff --git a/tests/searchcommands/test_internals_v2.py b/tests/searchcommands/test_internals_v2.py index c3122b3e..722aaae2 100755 --- a/tests/searchcommands/test_internals_v2.py +++ b/tests/searchcommands/test_internals_v2.py @@ -157,7 +157,7 @@ def test_record_writer_with_random_data(self, save_recording=False): test_data['metrics'] = metrics - for name, metric in list(metrics.items()): + for name, metric in metrics.items(): writer.write_metric(name, metric) self.assertEqual(writer._chunk_count, 0) @@ -172,8 +172,8 @@ def test_record_writer_with_random_data(self, save_recording=False): self.assertListEqual(writer._inspector['messages'], messages) self.assertDictEqual( - dict(k_v for k_v in list(writer._inspector.items()) if k_v[0].startswith('metric.')), - dict(('metric.' + k_v1[0], k_v1[1]) for k_v1 in list(metrics.items()))) + dict(k_v for k_v in writer._inspector.items() if k_v[0].startswith('metric.')), + dict(('metric.' + k_v1[0], k_v1[1]) for k_v1 in metrics.items())) writer.flush(finished=True) diff --git a/tests/test_conf.py b/tests/test_conf.py index 40c3f0f2..b00dbcc9 100755 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -87,7 +87,7 @@ def test_confs(self): testlib.tmpname(): testlib.tmpname()} stanza.submit(values) stanza.refresh() - for key, value in list(values.items()): + for key, value in values.items(): self.assertTrue(key in stanza) self.assertEqual(value, stanza[key]) diff --git a/tests/test_input.py b/tests/test_input.py index f97ca4b4..53436f73 100755 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -200,7 +200,7 @@ def setUp(self): def tearDown(self): super().tearDown() - for entity in list(self._test_entities.values()): + for entity in self._test_entities.values(): try: self.service.inputs.delete( kind=entity.kind, @@ -231,7 +231,7 @@ def test_lists_modular_inputs(self): def test_create(self): inputs = self.service.inputs - for entity in list(self._test_entities.values()): + for entity in self._test_entities.values(): self.check_entity(entity) self.assertTrue(isinstance(entity, client.Input)) @@ -242,7 +242,7 @@ def test_get_kind_list(self): def test_read(self): inputs = self.service.inputs - for this_entity in list(self._test_entities.values()): + for this_entity in self._test_entities.values(): kind, name = this_entity.kind, this_entity.name read_entity = inputs[name, kind] self.assertEqual(this_entity.kind, read_entity.kind) @@ -258,7 +258,7 @@ def test_read_indiviually(self): def test_update(self): inputs = self.service.inputs - for entity in list(self._test_entities.values()): + for entity in self._test_entities.values(): kind, name = entity.kind, entity.name kwargs = {'host': 'foo'} entity.update(**kwargs) @@ -269,7 +269,7 @@ def test_update(self): def test_delete(self): inputs = self.service.inputs remaining = len(self._test_entities) - 1 - for input_entity in list(self._test_entities.values()): + for input_entity in self._test_entities.values(): name = input_entity.name kind = input_entity.kind self.assertTrue(name in inputs)