← Back to team overview

curtin-dev team mailing list archive

[Merge] ~legovini/curtin:pin-flake8 into curtin:master

 

Paride Legovini has proposed merging ~legovini/curtin:pin-flake8 into curtin:master.

Commit message:
Fix flake8 E741 and pin flake8 to version 3.8.1

Changes:
 - Replace 'l' for 'L' to fix E741
 - Pin flake8 to version 3.8.1
 - Add a tox tip-flake8 environment

Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #1878236 in curtin: "flake8 >= 3.8.0 emits E741 ambiguous variable name 'l'"
  https://bugs.launchpad.net/curtin/+bug/1878236

For more details, see:
https://code.launchpad.net/~legovini/curtin/+git/curtin/+merge/383861
-- 
Your team curtin developers is requested to review the proposed merge of ~legovini/curtin:pin-flake8 into curtin:master.
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
index 35a91c6..4d7f694 100644
--- a/curtin/block/__init__.py
+++ b/curtin/block/__init__.py
@@ -1315,8 +1315,8 @@ def get_supported_filesystems():
     if not os.path.exists(proc_fs):
         raise RuntimeError("Unable to read 'filesystems' from %s" % proc_fs)
 
-    return [l.split('\t')[1].strip()
-            for l in util.load_file(proc_fs).splitlines()]
+    return [L.split('\t')[1].strip()
+            for L in util.load_file(proc_fs).splitlines()]
 
 
 def _discover_get_probert_data():
diff --git a/curtin/block/bcache.py b/curtin/block/bcache.py
index 188b4e0..a8bbf0d 100644
--- a/curtin/block/bcache.py
+++ b/curtin/block/bcache.py
@@ -318,11 +318,11 @@ def validate_bcache_ready(bcache_device, bcache_sys_path):
         LOG.debug("validating bcache caching device '%s' from sys_path"
                   " '%s'", bcache_device, bcache_sys_path)
         # we expect a cacheN symlink to point to bcache_device/bcache
-        sys_path_links = [os.path.join(bcache_sys_path, l)
-                          for l in os.listdir(bcache_sys_path)]
-        cache_links = [l for l in sys_path_links
-                       if os.path.islink(l) and (
-                          os.path.basename(l).startswith('cache'))]
+        sys_path_links = [os.path.join(bcache_sys_path, L)
+                          for L in os.listdir(bcache_sys_path)]
+        cache_links = [L for L in sys_path_links
+                       if os.path.islink(L) and (
+                          os.path.basename(L).startswith('cache'))]
 
         if len(cache_links) == 0:
             msg = ('Failed to find any cache links in %s:%s' % (
diff --git a/curtin/block/lvm.py b/curtin/block/lvm.py
index da29c7b..322febd 100644
--- a/curtin/block/lvm.py
+++ b/curtin/block/lvm.py
@@ -23,7 +23,7 @@ def _filter_lvm_info(lvtool, match_field, query_field, match_key, args=None):
                           '-o', ','.join([match_field, query_field])] + args,
                          capture=True)
     return [qf for (mf, qf) in
-            [l.strip().split(_SEP) for l in out.strip().splitlines()]
+            [L.strip().split(_SEP) for L in out.strip().splitlines()]
             if mf == match_key]
 
 
diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py
index 6ae5579..501b846 100644
--- a/tests/unittests/test_apt_source.py
+++ b/tests/unittests/test_apt_source.py
@@ -958,7 +958,7 @@ class TestDebconfSelections(CiTestCase):
         # assumes called with *args value.
         selections = m_set_sel.call_args_list[0][0][0].decode()
 
-        missing = [l for l in lines if l not in selections.splitlines()]
+        missing = [L for L in lines if L not in selections.splitlines()]
         self.assertEqual([], missing)
 
     @mock.patch("curtin.commands.apt_config.dpkg_reconfigure")
diff --git a/tests/unittests/test_block_dasd.py b/tests/unittests/test_block_dasd.py
index 95788b0..3772cc5 100644
--- a/tests/unittests/test_block_dasd.py
+++ b/tests/unittests/test_block_dasd.py
@@ -17,7 +17,7 @@ def random_device_id():
 
 class TestDasdValidDeviceId(CiTestCase):
 
-    nonhex = [l for l in string.ascii_lowercase if l not in
+    nonhex = [L for L in string.ascii_lowercase if L not in
               ['a', 'b', 'c', 'd', 'e', 'f']]
 
     invalids = [None, '', {}, ('', ), 12, '..', CiTestCase.random_string(),
diff --git a/tests/vmtests/test_fs_battery.py b/tests/vmtests/test_fs_battery.py
index ecd1729..067e91b 100644
--- a/tests/vmtests/test_fs_battery.py
+++ b/tests/vmtests/test_fs_battery.py
@@ -165,7 +165,7 @@ class TestFsBattery(VMBaseClass):
             "/etc /my/bind-ro-etc none bind,ro 0 0".split(),
         ]
         fstab_found = [
-            l.split() for l in self.load_collect_file("fstab").splitlines()]
+            L.split() for L in self.load_collect_file("fstab").splitlines()]
         self.assertEqual(expected, [e for e in expected if e in fstab_found])
 
     def test_mountinfo_has_mounts(self):
diff --git a/tests/vmtests/test_network.py b/tests/vmtests/test_network.py
index 601cad4..2657fdd 100644
--- a/tests/vmtests/test_network.py
+++ b/tests/vmtests/test_network.py
@@ -108,7 +108,7 @@ class TestNetworkBaseTestsAbs(VMBaseClass):
 
         eni_lines = eni.split('\n') + eni_cfg.split('\n')
         print("\n".join(eni_lines))
-        for line in [l for l in expected_eni.split('\n') if len(l) > 0]:
+        for line in [L for L in expected_eni.split('\n') if len(L) > 0]:
             if line.startswith("#"):
                 continue
             if "hwaddress ether" in line:
diff --git a/tox.ini b/tox.ini
index 6efc3f9..72d56d4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -48,7 +48,7 @@ commands = {envpython} -m flake8 {posargs:curtin}
 [testenv:py3-flake8]
 basepython = python3
 deps = {[testenv]deps}
-    flake8
+    flake8==3.8.1
 commands = {envpython} -m flake8 {posargs:curtin tests/}
 
 [testenv:py3-pyflakes]
@@ -144,6 +144,7 @@ deps = pycodestyle
 commands = {envpython} -m pyflakes {posargs:curtin/ tests/ tools/}
 deps = pyflakes
 
-[flake8]
-builtins = _
+[testenv:tip-flake8]
 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build
+deps = flake8
+commands = {envpython} -m flake8 {posargs:curtin/ tests/ tools/}

Follow ups