Fix other flake8 complaints

E231 missing whitespace after ','
E265 block comment should start with '# '
E266 too many leading '#' for block comment
E302 expected 2 blank lines, found 1
E501 line too long (115 > 88 characters)
E713 test for membership should be 'not in'
E722 do not use bare 'except'
F812 list comprehension redefines 'g' from line 1499
F821 undefined name 'cmp'
F841 local variable 'ex' is assigned to but never used

JIRA: COMPOSE-4108
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2020-02-07 10:50:25 +08:00
parent c0193c9fca
commit 65aa8fde2f
8 changed files with 25 additions and 24 deletions

View File

@ -136,7 +136,7 @@ def _try_read_cpuinfo(): # pragma: no cover
try:
with open("/proc/cpuinfo", "r") as f:
return f.readlines()
except:
except Exception:
return []
@ -147,7 +147,7 @@ def _parse_auxv(): # pragma: no cover
try:
with open("/proc/self/auxv", "rb") as f:
data = f.read()
except:
except Exception:
return
# Define values from /usr/include/elf.h
@ -223,7 +223,7 @@ def getCanonPPCArch(arch): # pragma: no cover
try:
if platform.startswith("power") and int(platform[5:].rstrip("+")) >= 7:
return "ppc64p7"
except:
except Exception:
pass
if machine is None:
@ -290,7 +290,7 @@ def getCanonArch(skipRpmPlatform=0): # pragma: no cover
f.close()
(arch, vendor, opersys) = line.split("-", 2)
return arch
except:
except Exception:
pass
arch = os.uname()[4]

View File

@ -310,9 +310,9 @@ class Compose(kobo.log.LoggingBase):
self.all_variants[variant.uid] = variant
# populate ci_base with variants - needed for layered-products (compose_id)
####FIXME - compose_to_composeinfo is no longer needed and has been
#### removed, but I'm not entirely sure what this is needed for
#### or if it is at all
# FIXME - compose_to_composeinfo is no longer needed and has been
# removed, but I'm not entirely sure what this is needed for
# or if it is at all
self.ci_base = compose_to_composeinfo(self)
def get_variants(self, types=None, arch=None):

View File

@ -450,7 +450,7 @@ class Pungi(PungiBase):
# deal with our repos
try:
self.ksparser.handler.repo.methodToRepo()
except:
except Exception:
pass
for repo in self.ksparser.handler.repo.repoList:
@ -777,7 +777,7 @@ class Pungi(PungiBase):
self.add_package(dep, msg)
added.add(dep)
except (yum.Errors.InstallError, yum.Errors.YumBaseError) as ex:
except (yum.Errors.InstallError, yum.Errors.YumBaseError):
self.logger.warning(
"Unresolvable dependency %s in %s.%s (repo: %s)",
r,
@ -1136,7 +1136,7 @@ class Pungi(PungiBase):
if self.is_resolve_deps:
# get conditional deps (defined in comps)
for txmbr in self.ayum.tsInfo:
if not txmbr.po in self.po_list:
if txmbr.po not in self.po_list:
if not is_package(txmbr.po):
# we don't want sources which can be pulled in,
# because 'src' arch is part of self.valid_arches
@ -1381,7 +1381,7 @@ class Pungi(PungiBase):
# flags
try:
srpm_po = self.sourcerpm_srpmpo_map[po.sourcerpm]
except:
except Exception:
self.logger.warning("Failed to find source for %s", po.sourcerpm)
srpm_po = None
if srpm_po in self.input_packages:
@ -1461,7 +1461,7 @@ class Pungi(PungiBase):
try:
pungi.util._link(local, target, self.logger, force=True)
continue
except:
except Exception:
self.logger.error("Unable to link %s from the yum cache." % po.name)
sys.exit(1)
@ -1492,9 +1492,9 @@ class Pungi(PungiBase):
# Filter out things we don't include
ourgroups = []
for item in self.ksparser.handler.packages.groupList:
g = self.ayum.comps.return_group(item.name)
if g:
ourgroups.append(g.groupid)
grp = self.ayum.comps.return_group(item.name)
if grp:
ourgroups.append(grp.groupid)
allgroups = [g.groupid for g in self.ayum.comps.get_groups()]
for group in allgroups:
if (
@ -1595,7 +1595,7 @@ class Pungi(PungiBase):
"flags": sorted(flags),
}
)
result.sort(lambda x, y: cmp(x["path"], y["path"]))
result.sort(lambda x, y: cmp(x["path"], y["path"])) # noqa: F821 (py2 only)
return result
def list_packages(self):
@ -1796,7 +1796,7 @@ class Pungi(PungiBase):
try:
# Convert url method to a repo
self.ksparser.handler.repo.methodToRepo()
except:
except Exception:
pass
for repo in self.ksparser.handler.repo.repoList:
@ -2028,7 +2028,7 @@ class Pungi(PungiBase):
stderr=subprocess.PIPE,
universal_newlines=True,
).communicate()
except:
except Exception:
self.logger.error("Got an error from rpm2cpio")
self.logger.error(err)
raise

View File

@ -336,7 +336,7 @@ def main():
if opts.do_all or opts.do_buildinstall:
try:
enforcing = selinux.security_getenforce()
except:
except Exception:
print("INFO: selinux disabled")
enforcing = False
if enforcing:

View File

@ -543,7 +543,7 @@ def find_old_compose(
with open(status_path, "r") as f:
if f.read().strip() in allowed_statuses:
composes.append((_sortable(i), os.path.abspath(path)))
except:
except Exception:
continue
if not composes:

View File

@ -514,7 +514,7 @@ def get_compose_data(compose_path):
}
)
return data
except Exception as exc:
except Exception:
return {}

View File

@ -49,7 +49,7 @@ setup(
"pungi-config-validate = pungi.scripts.config_validate:cli_main",
]
},
scripts=["contrib/yum-dnf-compare/pungi-compare-depsolving",],
scripts=["contrib/yum-dnf-compare/pungi-compare-depsolving"],
data_files=[
("/usr/share/pungi", glob.glob("share/*.xsl")),
("/usr/share/pungi", glob.glob("share/*.ks")),
@ -65,6 +65,6 @@ setup(
"six",
"dogpile.cache",
],
extras_require={':python_version=="2.7"': ["enum34", "lockfile", "dict.sorted",]},
tests_require=["mock", "nose", "nose-cov",],
extras_require={':python_version=="2.7"': ["enum34", "lockfile", "dict.sorted"]},
tests_require=["mock", "nose", "nose-cov"],
)

View File

@ -602,6 +602,7 @@ class TestSchemaValidator(unittest.TestCase):
{'enum': ['git://localhost/pungi-fedora.git'], 'type': 'string'})
self.assertEqual(scm_dict_properties["file"], {"type": "string"})
class TestUmask(unittest.TestCase):
def setUp(self):
self.orig_umask = os.umask(0)