diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-08-31 10:08:01 -0700 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2021-08-31 16:28:54 -0400 |
commit | b60bd0e299460c436acba43de27ac52afb11026b (patch) | |
tree | d1e66beb2c83625bfc86acbac7ce419980fd5013 | |
parent | 4d7031437c7a81b52c776d4ae1e32741bdb851ca (diff) | |
download | meson-b60bd0e299460c436acba43de27ac52afb11026b.zip meson-b60bd0e299460c436acba43de27ac52afb11026b.tar.gz meson-b60bd0e299460c436acba43de27ac52afb11026b.tar.bz2 |
pyllint: enable consider-user-enumerate
This caught a couple of cases of us doing:
```python
for i in range(len(x)):
v = x[i]
```
which are places to use enumerate instead.
It also caught a couple of cases of:
```python
assert len(x) == len(y)
for i in range(len(x)):
xv = x[i]
yv = y[i]
```
Which should instead be using zip()
```python
for xv, yv in zip(x, y):
...
```
-rw-r--r-- | .pylintrc | 1 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 3 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 3 | ||||
-rw-r--r-- | mesonbuild/backend/xcodebackend.py | 8 |
4 files changed, 5 insertions, 10 deletions
@@ -13,6 +13,7 @@ enable= bare-except, compare-to-zero, consider-iterating-dictionary, + consider-using-enumerate, dangerous-default-value, deprecated-lambda, len-as-condition, diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index ca9ab9a..204510e 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2193,8 +2193,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) infilelist = genlist.get_inputs() outfilelist = genlist.get_outputs() extra_dependencies = self.get_custom_target_depend_files(genlist) - for i in range(len(infilelist)): - curfile = infilelist[i] + for i, curfile in enumerate(infilelist): if len(generator.outputs) == 1: sole_output = os.path.join(self.get_target_private_dir(target), outfilelist[i]) else: diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 0cf0b72..13cd546 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -122,12 +122,11 @@ class Vs2010Backend(backends.Backend): source_dir = os.path.join(down, self.build_to_src, genlist.subdir) exe_arr = self.build_target_to_cmd_array(exe) idgroup = ET.SubElement(parent_node, 'ItemGroup') - for i in range(len(infilelist)): + for i, curfile in enumerate(infilelist): if len(infilelist) == len(outfilelist): sole_output = os.path.join(target_private_dir, outfilelist[i]) else: sole_output = '' - curfile = infilelist[i] infilename = os.path.join(down, curfile.rel_to_builddir(self.build_to_src)) deps = self.get_custom_target_depend_files(genlist, True) base_args = generator.get_arglist(infilename) diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 1139f79..5b3d33e 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -678,9 +678,7 @@ class XCodeBackend(backends.Backend): file_ids = self.generator_buildfile_ids[(tname, generator_id)] ref_ids = self.generator_fileref_ids[(tname, generator_id)] assert len(ref_ids) == len(file_ids) - for i in range(len(file_ids)): - file_o = file_ids[i] - ref_id = ref_ids[i] + for file_o, ref_id in zip(file_ids, ref_ids): odict = PbxDict() objects_dict.add_item(file_o, odict) odict.add_item('isa', 'PBXBuildFile') @@ -758,9 +756,7 @@ class XCodeBackend(backends.Backend): outputs = self.generator_outputs[(tname, generator_id)] ref_ids = self.generator_fileref_ids[tname, generator_id] assert len(ref_ids) == len(outputs) - for i in range(len(outputs)): - o = outputs[i] - ref_id = ref_ids[i] + for o, ref_id in zip(outputs, ref_ids): odict = PbxDict() name = os.path.basename(o) objects_dict.add_item(ref_id, odict, o) |