proj/pkgcore/pkgcore:master commit in: tests/sync/, tests/restrictions/, tests/package/, doc/, tests/config/, examples/, ...
"Arthur Zamarin" <[email protected]>
| Newsgroups | gmane.linux.gentoo.cvs |
|---|---|
| Message-ID | <1786128957.624a12e45bc622eded0c6a002233e3f50e4601df.arthurzam@gentoo> |
commit: 624a12e45bc622eded0c6a002233e3f50e4601df
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 7 18:55:57 2026 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 7 18:55:57 2026 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=624a12e4
fix ruff lint
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
doc/conf.py | 1 -
examples/changed_use.py | 9 ++------
examples/pkg_info.py | 9 ++------
examples/repo_list.py | 8 +++----
examples/report_pkg_changes.py | 13 ++++-------
tests/config/test_basics.py | 10 ++++----
tests/config/test_cparser.py | 12 +---------
tests/ebuild/test_atom.py | 6 ++---
tests/ebuild/test_conditionals.py | 14 ++++++------
tests/ebuild/test_cpv.py | 2 +-
tests/ebuild/test_digest.py | 2 +-
tests/ebuild/test_ebuild_src.py | 40 ++++++++++++++++----------------
tests/ebuild/test_eclass.py | 6 ++---
tests/ebuild/test_formatter.py | 12 +++++-----
tests/ebuild/test_misc.py | 6 ++---
tests/ebuild/test_portage_conf.py | 2 +-
tests/ebuild/test_profiles.py | 6 ++---
tests/ebuild/test_repo_objs.py | 4 ++--
tests/ebuild/test_repository.py | 6 ++---
tests/fetch/test_base.py | 4 ++--
tests/fetch/test_init.py | 2 +-
tests/fs/test_contents.py | 9 +-------
tests/fs/test_livefs.py | 5 ++--
tests/fs/test_ops.py | 6 ++---
tests/merge/test_engine.py | 2 +-
tests/merge/test_triggers.py | 6 ++---
tests/package/test_base.py | 2 +-
tests/package/test_mutated.py | 4 ++--
tests/repository/test_multiplex.py | 4 ++--
tests/repository/test_prototype.py | 4 ++--
tests/resolver/test_choice_point.py | 8 +++----
tests/resolver/test_pigeonholes.py | 2 +-
tests/restrictions/test_boolean.py | 18 ++++++++-------
tests/restrictions/test_delegated.py | 44 +++++++++++++-----------------------
tests/restrictions/test_values.py | 4 ++--
tests/scripts/test_pmaint.py | 8 +++----
tests/sync/test_base.py | 15 ++++++------
tests/sync/test_bzr.py | 2 +-
tests/sync/test_git_svn.py | 2 --
39 files changed, 135 insertions(+), 184 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index 29a06b930..fdb2fa51a 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# pkgcore documentation build configuration file, created by
# sphinx-quickstart on Sun Aug 1 16:23:57 2010.
diff --git a/examples/changed_use.py b/examples/changed_use.py
index d5d8fc9a4..8301326c0 100755
--- a/examples/changed_use.py
+++ b/examples/changed_use.py
@@ -65,18 +65,13 @@ def main(options, out, err):
changed_flags = (oldflags ^ newflags) | (current.iuse ^ built.iuse)
if options.verbosity > 0:
out.write(
- "package %s, %d flags have changed:\n\t%s"
- % (
- current.unversioned_atom,
- len(changed_flags),
- " ".join(changed_flags),
- )
+ f"package {current.unversioned_atom}, {len(changed_flags)} flags have changed:\n\t{' '.join(changed_flags)}"
)
else:
out.write(options.outputter(current))
else:
if options.verbosity > 0:
- out.write("%s is the same as it was before" % current.cpvstr)
+ out.write(f"{current.cpvstr} is the same as it was before")
if __name__ == "__main__":
diff --git a/examples/pkg_info.py b/examples/pkg_info.py
index aa13de2d5..8bf755378 100755
--- a/examples/pkg_info.py
+++ b/examples/pkg_info.py
@@ -43,18 +43,13 @@ def main(options, out, err):
out.write(t[0])
out.first_prefix = " "
for pkg in pkgs:
- out.write("%s::%s" % (pkg.cpvstr, pkg.repo.repo_id))
+ out.write(f"{pkg.cpvstr}::{pkg.repo.repo_id}")
out.first_prefix = ""
item = "maintainer"
values = t[1]
if values:
out.write(
- "%s%s: %s"
- % (
- item.title(),
- "s"[len(values) == 1 :],
- ", ".join(str(x) for x in values),
- )
+ f"{item.title()}{'s'[len(values) == 1 :]}: {', '.join(str(x) for x in values)}"
)
out.write()
diff --git a/examples/repo_list.py b/examples/repo_list.py
index 3c5114baa..d47d85e12 100755
--- a/examples/repo_list.py
+++ b/examples/repo_list.py
@@ -41,14 +41,14 @@ def check_args(parser, namespace):
@argparser.bind_main_func
def main(options, out, err):
for repo in options.repos:
- out.write("Repo ID: %s" % repo.repo_id)
+ out.write(f"Repo ID: {repo.repo_id}")
location = getattr(repo, "location", None)
if location:
- out.write("Repo location: %s" % location)
+ out.write(f"Repo location: {location}")
else:
out.write("Repo has no on-disk location")
- out.write("%d packages" % len(repo.versions))
- out.write("%d categories" % len(repo.packages))
+ out.write(f"{len(repo.versions)} packages")
+ out.write(f"{len(repo.packages)} categories")
out.write()
diff --git a/examples/report_pkg_changes.py b/examples/report_pkg_changes.py
index 6b459ddbd..8f1fe8c69 100755
--- a/examples/report_pkg_changes.py
+++ b/examples/report_pkg_changes.py
@@ -16,7 +16,7 @@ from pkgcore.pkgsets.filelist import WorldFile
def main(target_repo, seen, moves):
# could build the atom from categories/packages, but prefer this;
# simpler.
- new_seen = set(atom("%s/%s" % x) for x in target_repo.versions)
+ new_seen = {atom(f"{x[0]}/{x[1]}") for x in target_repo.versions}
new_pkgs = new_seen.difference(seen)
# this is simpler if pkgsets are... actually sets. ;)
@@ -38,18 +38,16 @@ def main(target_repo, seen, moves):
for l, prefix in ((new_pkgs, "added pkgs"), (removed, "removed pkgs")):
if l:
sys.stdout.write(
- "%s:\n %s\n\n" % (prefix, "\n ".join(str(x) for x in sorted(l)))
+ f"{prefix}:\n {'\n '.join(str(x) for x in sorted(l))}\n\n"
)
if finished_moves:
sys.stdout.write(
- "moved pkgs:\n %s\n\n"
- % "\n ".join("%s -> %s" % (k, moves[k]) for k in sorted(finished_moves))
+ f"moved pkgs:\n {'\n '.join(f'{k} -> {moves[k]}' for k in sorted(finished_moves))}\n\n"
)
if in_transit:
sys.stdout.write(
- "pkg moves in transit:\n %s\n\n"
- % "\n ".join("%s -> %s" % (k, in_transit[k]) for k in sorted(in_transit))
+ f"pkg moves in transit:\n {'\n '.join(f'{k} -> {in_transit[k]}' for k in sorted(in_transit))}\n\n"
)
# just flush the seen fully, simplest.
@@ -102,8 +100,7 @@ if __name__ == "__main__":
repo = conf.repo[args[0]]
except KeyError:
sys.stderr.write(
- "repository %r wasn't found- known repos\n%r\n"
- % (args[0], list(conf.repo.keys()))
+ f"repository {args[0]!r} wasn't found- known repos\n{list(conf.repo.keys())}\n"
)
sys.exit(-2)
diff --git a/tests/config/test_basics.py b/tests/config/test_basics.py
index 10f0841e1..24da1713c 100644
--- a/tests/config/test_basics.py
+++ b/tests/config/test_basics.py
@@ -42,7 +42,7 @@ def nonopt(one, two):
"""Function taking two non-optional args."""
-def alltypes(alist=(), astr="astr", abool=True, aref=object(), anint=3, along=int(3)):
+def alltypes(alist=(), astr="astr", abool=True, aref=object(), anint=3, along=3):
"""Function taking lots of kinds of args."""
@@ -269,9 +269,7 @@ class TestConvertString:
# reprs
for typename, value in source.items():
- assert ("str", value) == basics.convert_string(
- None, source[typename], "repr"
- )
+ assert ("str", value) == basics.convert_string(None, value, "repr")
# invalid gets
# not callable
with pytest.raises(errors.ConfigurationError):
@@ -317,10 +315,10 @@ class TestConvertString:
except KeyError:
raise errors.ConfigurationError(section)
- assert [config1, config2] == list(
+ assert [config1, config2] == [
ref.collapse()
for ref in basics.convert_string(TestCentral(), "1 2", "refs:spoon")
- )
+ ]
lazy_refs = basics.convert_string(TestCentral(), "2 3", "refs:spoon")
assert len(lazy_refs) == 2
with pytest.raises(errors.ConfigurationError):
diff --git a/tests/config/test_cparser.py b/tests/config/test_cparser.py
index bf407e62c..58fc89169 100644
--- a/tests/config/test_cparser.py
+++ b/tests/config/test_cparser.py
@@ -8,17 +8,7 @@ from pkgcore.config import central, cparser, errors
def test_case_sensitive_config_parser():
cp = cparser.CaseSensitiveConfigParser()
- config = StringIO(
- "\n".join(
- (
- "[header]",
- "foo=bar",
- "FOO=BAR",
- "[HEADER]",
- "foo=notbar",
- )
- )
- )
+ config = StringIO("[header]\nfoo=bar\nFOO=BAR\n[HEADER]\nfoo=notbar")
cp.read_file(config)
assert cp.get("header", "foo") == "bar"
assert cp.get("header", "FOO") == "BAR"
diff --git a/tests/ebuild/test_atom.py b/tests/ebuild/test_atom.py
index d3be24915..7c2df0591 100644
--- a/tests/ebuild/test_atom.py
+++ b/tests/ebuild/test_atom.py
@@ -81,7 +81,7 @@ class TestAtom(TestRestriction):
pytest.raises(errors.MalformedAtom, self.kls, "!!dev-util/diffball", eapi="0")
pytest.raises(errors.MalformedAtom, self.kls, "!!dev-util/diffball", eapi="1")
pytest.raises(errors.MalformedAtom, self.kls, "!!!dev-util/diffball", eapi="2")
- for x in range(0, 2):
+ for x in range(2):
obj = self.kls("!dev-util/diffball", eapi=str(x))
assert obj.blocks
assert obj.blocks_temp_ignorable
@@ -371,7 +371,7 @@ class TestAtom(TestRestriction):
# assert it explodes for bad attr access.
obj = self.kls("dev-util/diffball")
with pytest.raises(AttributeError):
- obj.__foasdfawe
+ _ = obj.__foasdfawe
# assert ordering
def assertAttr(attr):
@@ -476,7 +476,7 @@ class TestAtom(TestRestriction):
self.kls("dev-util/foon::-gentoo-x86")
with pytest.raises(errors.MalformedAtom):
self.kls("dev-util/foon:::")
- for x in range(0, 3):
+ for x in range(3):
with pytest.raises(errors.MalformedAtom):
self.kls("dev-util/foon::gentoo-x86", eapi=str(x))
diff --git a/tests/ebuild/test_conditionals.py b/tests/ebuild/test_conditionals.py
index cc62fa9d5..e764c64e2 100644
--- a/tests/ebuild/test_conditionals.py
+++ b/tests/ebuild/test_conditionals.py
@@ -265,7 +265,7 @@ class TestDepSetConditionalsInspection(base):
d = {element_kls(k): v for k, v in r.items()}
for k, v in d.items():
if isinstance(v, str):
- d[k] = set([frozenset(v.split())])
+ d[k] = {frozenset(v.split())}
elif isinstance(v, (tuple, list)):
d[k] = set(map(frozenset, v))
@@ -304,7 +304,7 @@ class TestDepSetConditionalsInspection(base):
class TestDepSetEvaluate(base):
def test_evaluation(self):
- flag_set = list(sorted(f"x{x}" for x in range(2000)))
+ flag_set = sorted(f"x{x}" for x in range(2000))
for vals in (
("y", "x? ( y ) !x? ( z )", "x"),
("z", "x? ( y ) !x? ( z )"),
@@ -328,22 +328,22 @@ class TestDepSetEvaluate(base):
# worst case (jython), we want to force a memory exhaustion.
# we assert it in the tests to make sure some 'special' ebuild dev doesn't trigger
# it on a user's machine, thus the abuse leveled here.
- ("a/b", "a/b[!c?,%s]" % (",".join(x + "?" for x in flag_set)), "c"),
+ ("a/b", f"a/b[!c?,{','.join(x + '?' for x in flag_set)}]", "c"),
(
"a/b",
- "a/b[%s]" % (",".join("%s?" % (x,) for x in flag_set)),
+ f"a/b[{','.join(f'{x}?' for x in flag_set)}]",
"",
" ".join(flag_set),
),
(
"a/b[c,x0]",
- "a/b[c?,%s]" % (",".join(x + "?" for x in flag_set)),
+ f"a/b[c?,{','.join(x + '?' for x in flag_set)}]",
"c",
" ".join(flag_set[1:]),
),
(
- "a/b[c,%s]" % (",".join(flag_set),),
- "a/b[c?,%s]" % (",".join(x + "?" for x in flag_set)),
+ f"a/b[c,{','.join(flag_set)}]",
+ f"a/b[c?,{','.join(x + '?' for x in flag_set)}]",
"c",
"",
),
diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py
index ab85af540..98d885f05 100644
--- a/tests/ebuild/test_cpv.py
+++ b/tests/ebuild/test_cpv.py
@@ -381,7 +381,7 @@ class TestCPV:
def test_attribute_errors(self):
obj = cpv.VersionedCPV("foo/bar-0")
- assert not obj == 0
+ assert not obj == 0 # noqa: SIM201
assert obj != 0
with pytest.raises(TypeError):
assert obj < 0
diff --git a/tests/ebuild/test_digest.py b/tests/ebuild/test_digest.py
index c7f0af54d..bf54c094e 100644
--- a/tests/ebuild/test_digest.py
+++ b/tests/ebuild/test_digest.py
@@ -18,7 +18,7 @@ MD5 2fa54dd51b6a8f1c46e5baf741e90f7e python-2.4-patches-1.tar.bz2 7820
RMD160 313c0f4f4dea59290c42a9b2c8de1db159f1ca1b python-2.4-patches-1.tar.bz2 7820
SHA256 e22abe4394f1f0919aac429f155c00ec1b3fe94cdc302119059994d817cd30b5 python-2.4-patches-1.tar.bz2 7820"""
digest_chksum = (
- ("size", int(7853169)),
+ ("size", 7853169),
("md5", int("98db1465629693fc434d4dc52db93838", 16)),
("rmd160", int("c511d2b76b5394742d285e71570a2bcd3c1fa871", 16)),
(
diff --git a/tests/ebuild/test_ebuild_src.py b/tests/ebuild/test_ebuild_src.py
index 34b049f42..f1b58ea4e 100644
--- a/tests/ebuild/test_ebuild_src.py
+++ b/tests/ebuild/test_ebuild_src.py
@@ -148,14 +148,14 @@ class TestBase:
else:
o = self.get_pkg({"EAPI": eapi_str, "SLOT": "0/0"})
with pytest.raises(errors.MetadataException):
- o.fullslot
+ _ = o.fullslot
# unset SLOT variable
with pytest.raises(errors.MetadataException):
- self.get_pkg({}).fullslot
+ _ = self.get_pkg({}).fullslot
# empty SLOT variable
with pytest.raises(errors.MetadataException):
- self.get_pkg({"SLOT": ""}).fullslot
+ _ = self.get_pkg({"SLOT": ""}).fullslot
def test_slot(self):
o = self.get_pkg({"SLOT": "0"})
@@ -171,14 +171,14 @@ class TestBase:
else:
o = self.get_pkg({"EAPI": eapi_str, "SLOT": "1/2"})
with pytest.raises(errors.MetadataException):
- o.slot
+ _ = o.slot
# unset SLOT variable
with pytest.raises(errors.MetadataException):
- self.get_pkg({}).slot
+ _ = self.get_pkg({}).slot
# empty SLOT variable
with pytest.raises(errors.MetadataException):
- self.get_pkg({"SLOT": ""}).slot
+ _ = self.get_pkg({"SLOT": ""}).slot
def test_subslot(self):
o = self.get_pkg({"SLOT": "0"})
@@ -196,14 +196,14 @@ class TestBase:
else:
o = self.get_pkg({"EAPI": eapi_str, "SLOT": "1/2"})
with pytest.raises(errors.MetadataException):
- o.subslot
+ _ = o.subslot
# unset SLOT variable
with pytest.raises(errors.MetadataException):
- self.get_pkg({}).subslot
+ _ = self.get_pkg({}).subslot
# empty SLOT variable
with pytest.raises(errors.MetadataException):
- self.get_pkg({"SLOT": ""}).subslot
+ _ = self.get_pkg({"SLOT": ""}).subslot
def test_restrict(self):
o = self.get_pkg({"RESTRICT": "strip fetch strip"})
@@ -212,7 +212,7 @@ class TestBase:
assert sorted(o.restrict.evaluate_depset([])) == ["dar"]
# ensure restrict doesn't have || () in it
with pytest.raises(errors.MetadataException):
- getattr(self.get_pkg({"RESTRICT": "|| ( foon dar )"}), "restrict")
+ _ = self.get_pkg({"RESTRICT": "|| ( foon dar )"}).restrict
def test_eapi(self):
assert str(self.get_pkg({"EAPI": "0"}).eapi) == "0"
@@ -220,17 +220,17 @@ class TestBase:
assert not self.get_pkg({"EAPI": "0.1"}).eapi.supported
assert self.get_pkg({"EAPI": "foon"}, suppress_unsupported=False).eapi is None
with pytest.raises(errors.MetadataException):
- getattr(self.get_pkg({"EAPI": 0, "DEPEND": "d/b:0"}), "depend")
+ _ = self.get_pkg({"EAPI": 0, "DEPEND": "d/b:0"}).depend
with pytest.raises(errors.MetadataException):
- getattr(self.get_pkg({"EAPI": 0, "RDEPEND": "d/b:0"}), "rdepend")
+ _ = self.get_pkg({"EAPI": 0, "RDEPEND": "d/b:0"}).rdepend
with pytest.raises(errors.MetadataException):
- getattr(self.get_pkg({"EAPI": 1, "DEPEND": "d/b[x,y]"}), "depend")
+ _ = self.get_pkg({"EAPI": 1, "DEPEND": "d/b[x,y]"}).depend
with pytest.raises(errors.MetadataException):
- getattr(self.get_pkg({"EAPI": 1, "DEPEND": "d/b::foon"}), "depend")
+ _ = self.get_pkg({"EAPI": 1, "DEPEND": "d/b::foon"}).depend
assert self.get_pkg({"EAPI": 2, "DEPEND": "a/b[x=]"}).depend.node_conds
pkg = self.get_pkg({"EAPI": 1, "DEPEND": "a/b[x=]"})
with pytest.raises(errors.MetadataException):
- getattr(pkg, "depend")
+ _ = pkg.depend
def test_get_parsed_eapi(self, tmpdir):
# ebuild has a real path on the fs
@@ -254,7 +254,7 @@ class TestBase:
for func in (_path, _src):
# verify parsing known EAPIs
- for eapi_str in EAPI.known_eapis.keys():
+ for eapi_str in EAPI.known_eapis:
c = self.make_parent(get_ebuild_src=post_curry(func, eapi_str))
o = self.get_pkg({"EAPI": None}, repo=c)
assert str(o.eapi) == eapi_str
@@ -369,11 +369,11 @@ class TestBase:
# verify it does digest lookups...
o = self.get_pkg({"SRC_URI": "http://foo.com/bar.tgz"}, repo=parent)
with pytest.raises(errors.MetadataException):
- getattr(o, "fetchables")
+ _ = o.fetchables
assert l == [o]
# basic tests;
- for x in range(0, 3):
+ for x in range(3):
f = self.get_pkg(
{"SRC_URI": "http://foo.com/monkey.tgz", "EAPI": str(x)}, repo=parent
).fetchables
@@ -404,7 +404,7 @@ class TestBase:
{"SRC_URI": "http://foo.com/monkey.tgz -> ", "EAPI": "2"}, repo=parent
)
with pytest.raises(errors.MetadataException):
- getattr(o, "fetchables")
+ _ = o.fetchables
# verify it collapses multiple basenames down to the same.
f = self.get_pkg(
@@ -554,7 +554,7 @@ class TestBase:
{"EAPI": eapi_str, "REQUIRED_USE": "?? ( bar foo )"}
)
with pytest.raises(errors.MetadataException) as cm:
- getattr(pkg, "required_use")
+ _ = pkg.required_use
assert (
f"EAPI '{eapi_str}' doesn't support '??' operator"
in cm.value.error
diff --git a/tests/ebuild/test_eclass.py b/tests/ebuild/test_eclass.py
index bc95c1fb9..6a7969249 100644
--- a/tests/ebuild/test_eclass.py
+++ b/tests/ebuild/test_eclass.py
@@ -12,9 +12,9 @@ class FakeEclass:
class FakeEclassCache:
def __init__(self, temp_dir, eclasses):
- self.eclasses = dict(
- (name, FakeEclass(name, contents)) for name, contents in eclasses.items()
- )
+ self.eclasses = {
+ name: FakeEclass(name, contents) for name, contents in eclasses.items()
+ }
def get_eclass(self, name):
return self.eclasses.get(name)
diff --git a/tests/ebuild/test_formatter.py b/tests/ebuild/test_formatter.py
index cedb9eff1..05880d6fd 100644
--- a/tests/ebuild/test_formatter.py
+++ b/tests/ebuild/test_formatter.py
@@ -914,7 +914,7 @@ class TestPortageFormatter(BaseFormatterTest):
)
def test_use_expand(self):
- self.formatter = self.newFormatter(use_expand=set(["foo", "bar"]))
+ self.formatter = self.newFormatter(use_expand={"foo", "bar"})
self.formatter.format(
FakeOp(
FakeEbuildSrc(
@@ -959,7 +959,7 @@ class TestPortageFormatter(BaseFormatterTest):
)
def test_disabled_use(self):
- self.formatter.pkg_get_use = lambda pkg: (set(), set(), set(["static"]))
+ self.formatter.pkg_get_use = lambda pkg: (set(), set(), {"static"})
self.formatter.format(
FakeOp(
@@ -995,7 +995,7 @@ class TestPortageFormatter(BaseFormatterTest):
)
def test_forced_use(self):
- self.formatter.pkg_get_use = lambda pkg: (set(["static"]), set(), set())
+ self.formatter.pkg_get_use = lambda pkg: ({"static"}, set(), set())
# new pkg: static use flag forced on
self.formatter.format(
@@ -1090,8 +1090,8 @@ class TestPortageFormatter(BaseFormatterTest):
)
def test_forced_use_expand(self):
- self.formatter = self.newFormatter(use_expand=set(["ABI_X86", "TARGETS"]))
- self.formatter.pkg_get_use = lambda pkg: (set(["targets_X86"]), set(), set())
+ self.formatter = self.newFormatter(use_expand={"ABI_X86", "TARGETS"})
+ self.formatter.pkg_get_use = lambda pkg: ({"targets_X86"}, set(), set())
# rebuilt pkg: new abi_x86_64 and targets_X86 USE flags,
# with abi_x86_64 disabled and targets_X86 forced on
@@ -1645,7 +1645,7 @@ class TestPortageVerboseFormatter(TestPortageFormatter):
)
def test_forced_use_verbose(self):
- self.formatter.pkg_get_use = lambda pkg: (set(["static"]), set(), set())
+ self.formatter.pkg_get_use = lambda pkg: ({"static"}, set(), set())
# rebuilt pkg: unchanged static use flag forced on
self.formatter.format(
diff --git a/tests/ebuild/test_misc.py b/tests/ebuild/test_misc.py
index 3c656a200..106a26929 100644
--- a/tests/ebuild/test_misc.py
+++ b/tests/ebuild/test_misc.py
@@ -16,8 +16,8 @@ class Test_collapsed_restrict_to_data:
atoms_dict = {a[0].key: (a, a[1]) for a in atoms}
assert set(obj.atoms) == set(atoms_dict)
for k, v in obj.atoms.items():
- l1 = set((x[0], list(x[1])) for x in v)
- l2 = set((x[0], list(x[1])) for x, y in atoms_dict[k])
+ l1 = {(x[0], list(x[1])) for x in v}
+ l2 = {(x[0], list(x[1])) for x, y in atoms_dict[k]}
assert l1 == l2, f"for {k!r} atom, got {l1!r}, expected {l2!r}"
def test_defaults(self):
@@ -56,7 +56,7 @@ class TestIncrementalExpansion:
def test_IncrementalsDict():
- d = misc.IncrementalsDict(frozenset("i1 i2".split()), a1="1", i1="1")
+ d = misc.IncrementalsDict(frozenset({"i1", "i2"}), a1="1", i1="1")
expected = {"a1": "1", "i1": "1"}
assert d == expected
d["a1"] = "2"
diff --git a/tests/ebuild/test_portage_conf.py b/tests/ebuild/test_portage_conf.py
index 8d88f73eb..93a51f59d 100644
--- a/tests/ebuild/test_portage_conf.py
+++ b/tests/ebuild/test_portage_conf.py
@@ -106,7 +106,7 @@ class TestReposConf:
location = /var/gentoo/repos/gentoo"""
)
)
- defaults, repos = load_repos_conf(path)
+ _defaults, repos = load_repos_conf(path)
assert repos["foo"]["priority"] == 0
assert "'foo' repo has invalid priority setting" in caplog.text
diff --git a/tests/ebuild/test_profiles.py b/tests/ebuild/test_profiles.py
index 148f2abdf..0eefbeac4 100644
--- a/tests/ebuild/test_profiles.py
+++ b/tests/ebuild/test_profiles.py
@@ -800,9 +800,9 @@ class TestPmsProfileNode(profile_mixin):
self.write_file(tmp_path, "parent", "..", profile=profile2)
self.write_file(tmp_path, "make.defaults", "USE=-foo", profile=profile3)
self.write_file(tmp_path, "parent", "..", profile=profile3)
- assert self.klass(profile1).default_env == dict(USE="foo")
- assert self.klass(profile2).default_env == dict(USE="foo", x="dar")
- assert self.klass(profile3).default_env == dict(USE="foo -foo", x="dar")
+ assert self.klass(profile1).default_env == {"USE": "foo"}
+ assert self.klass(profile2).default_env == {"USE": "foo", "x": "dar"}
+ assert self.klass(profile3).default_env == {"USE": "foo -foo", "x": "dar"}
def test_bashrc(self, tmp_path):
path = tmp_path / self.profile
diff --git a/tests/ebuild/test_repo_objs.py b/tests/ebuild/test_repo_objs.py
index cdc32b373..858b55981 100644
--- a/tests/ebuild/test_repo_objs.py
+++ b/tests/ebuild/test_repo_objs.py
@@ -138,7 +138,7 @@ class TestMetadataXml:
def test_local_use(self):
# empty...
- assert dict() == self.get_metadata_xml().local_use
+ assert {} == self.get_metadata_xml().local_use
local_use = {
"foo": "description for foo",
@@ -146,7 +146,7 @@ class TestMetadataXml:
}
metadata_xml = self.get_metadata_xml(local_use=local_use)
pkg_tag_re = re.compile(r"</?pkg>")
- local_use = dict((k, pkg_tag_re.sub("", v)) for k, v in local_use.items())
+ local_use = {k: pkg_tag_re.sub("", v) for k, v in local_use.items()}
assert local_use == metadata_xml.local_use
def test_longdesc(self):
diff --git a/tests/ebuild/test_repository.py b/tests/ebuild/test_repository.py
index af66fd51d..e848875f4 100644
--- a/tests/ebuild/test_repository.py
+++ b/tests/ebuild/test_repository.py
@@ -17,7 +17,7 @@ class TestUnconfiguredTree:
eclasses = eclass_cache.cache(str(epath))
(path / "profiles").mkdir(exist_ok=True)
return repository.UnconfiguredTree(
- str(path), eclass_cache=eclasses, *args, **kwds
+ str(path), *args, eclass_cache=eclasses, **kwds
)
@pytest.fixture
@@ -239,11 +239,11 @@ class TestSlavedTree(TestUnconfiguredTree):
eclasses = eclass_cache.cache(str(epath))
self.master_repo = repository.UnconfiguredTree(
- str(self.dir_master), eclass_cache=eclasses, *args, **kwds
+ str(self.dir_master), *args, eclass_cache=eclasses, **kwds
)
masters = (self.master_repo,)
return repository.UnconfiguredTree(
- str(self.dir_slave), eclass_cache=eclasses, masters=masters, *args, **kwds
+ str(self.dir_slave), *args, eclass_cache=eclasses, masters=masters, **kwds
)
@pytest.fixture(autouse=True)
diff --git a/tests/fetch/test_base.py b/tests/fetch/test_base.py
index 42d27750f..9005b141c 100644
--- a/tests/fetch/test_base.py
+++ b/tests/fetch/test_base.py
@@ -20,7 +20,7 @@ def _callback(chf):
chksums = LazyValDict(frozenset(handlers.keys()), _callback)
# get a non size based chksum
-known_chksum = [x for x in handlers.keys() if x != "size"][0]
+known_chksum = next(x for x in handlers if x != "size")
class TestFetcher:
@@ -53,7 +53,7 @@ class TestFetcher:
def test_verify_all_chksums(self):
self.write_data()
- subhandlers = dict([list(handlers.items())[0]])
+ subhandlers = dict([next(iter(handlers.items()))])
with pytest.raises(errors.RequiredChksumDataMissing):
self.fetcher._verify(self.fp, self.obj, handlers=subhandlers)
self.fetcher._verify(self.fp, self.obj)
diff --git a/tests/fetch/test_init.py b/tests/fetch/test_init.py
index c9f4c7b39..94d682650 100644
--- a/tests/fetch/test_init.py
+++ b/tests/fetch/test_init.py
@@ -19,7 +19,7 @@ class TestFetchable:
def test_eq_ne(self):
o1 = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf": 1})
- assert o1 == o1
+ assert o1 == o1 # noqa: PLR0124
o2 = fetch.fetchable("dar", uri=["asdf"], chksums={"asdf": 1})
assert o1 == o2
assert o1 != fetch.fetchable("dar1", uri=["asdf"], chksums={"asdf": 1})
diff --git a/tests/fs/test_contents.py b/tests/fs/test_contents.py
index 32734af40..f4012422c 100644
--- a/tests/fs/test_contents.py
+++ b/tests/fs/test_contents.py
@@ -50,9 +50,7 @@ class TestContentsSet:
for x in self.links:
cs.add(x)
assert x in cs
- assert len(cs) == len(
- set(x.location for x in self.files + self.dirs + self.links)
- )
+ assert len(cs) == len({x.location for x in self.files + self.dirs + self.links})
with pytest.raises(AttributeError):
contents.contentsSet(mutable=False).add(self.devs[0])
with pytest.raises(TypeError):
@@ -280,11 +278,6 @@ class TestContentsSet:
[mk_file("/dev"), mk_file("/dar")],
[mk_file("/dev"), mk_file("/dar"), mk_file("/asdf")],
),
- (
- False,
- [mk_file("/dev"), mk_file("/dar")],
- [mk_file("/dev"), mk_file("/dar"), mk_file("/asdf")],
- ),
(
True,
[mk_file("/dev"), mk_file("/dar")],
diff --git a/tests/fs/test_livefs.py b/tests/fs/test_livefs.py
index 3dbad6125..31efa7794 100644
--- a/tests/fs/test_livefs.py
+++ b/tests/fs/test_livefs.py
@@ -28,9 +28,8 @@ class TestFsObjs:
o = livefs.gen_obj("/tmp/etc/passwd", real_location="/etc/passwd")
assert o.location, "/tmp/etc/passwd"
assert o.data.path, "/etc/passwd"
- with open("/etc/passwd", "rb") as f:
- with o.data.bytes_fileobj() as fileobj:
- assert fileobj.read() == f.read()
+ with open("/etc/passwd", "rb") as f, o.data.bytes_fileobj() as fileobj:
+ assert fileobj.read() == f.read()
def test_gen_obj_reg(self, tmp_path):
(path := tmp_path / "reg_obj").touch()
diff --git a/tests/fs/test_ops.py b/tests/fs/test_ops.py
index bc80527dd..95acad279 100644
--- a/tests/fs/test_ops.py
+++ b/tests/fs/test_ops.py
@@ -166,7 +166,7 @@ class TestMergeContents(ContentsMixin):
"generic_merge_bits", ("entries_norm1", "entries_rec1"), indirect=True
)
def test_callback(self, generic_merge_bits):
- src, dest, cset = generic_merge_bits
+ _src, dest, cset = generic_merge_bits
new_cset = contents.contentsSet(contents.offset_rewriter(dest, cset))
s = set(new_cset)
ops.merge_contents(cset, offset=dest, callback=s.remove)
@@ -182,7 +182,7 @@ class TestMergeContents(ContentsMixin):
@pytest.mark.parametrize("generic_merge_bits", ("entries_norm1",), indirect=True)
def test_exact_overwrite(self, generic_merge_bits):
- src, dest, cset = generic_merge_bits
+ _src, dest, cset = generic_merge_bits
assert ops.merge_contents(cset, offset=dest)
def test_sym_over_dir(self, tmp_path):
@@ -238,7 +238,7 @@ class TestUnmergeContents(ContentsMixin):
@pytest.mark.parametrize("generic_unmerge_bits", ("entries_norm1",), indirect=True)
def test_empty_removal(self, tmp_path, generic_unmerge_bits):
- img, cset = generic_unmerge_bits
+ _img, cset = generic_unmerge_bits
assert ops.unmerge_contents(cset, offset=str(tmp_path / "dest"))
@pytest.mark.parametrize("generic_unmerge_bits", ("entries_norm1",), indirect=True)
diff --git a/tests/merge/test_engine.py b/tests/merge/test_engine.py
index f4650860c..cb92f979b 100644
--- a/tests/merge/test_engine.py
+++ b/tests/merge/test_engine.py
@@ -18,7 +18,7 @@ class fake_pkg:
class TestMergeEngineCsets:
- simple_cset = list(fsFile(x) for x in ("/foon", "/usr/dar", "/blah"))
+ simple_cset = [fsFile(x) for x in ("/foon", "/usr/dar", "/blah")]
simple_cset.extend(fsDir(x) for x in ("/usr", "/usr/lib"))
simple_cset.append(fsSymlink("/usr/lib/blah", "../../blah"))
simple_cset.append(fsSymlink("/broken-symlink", "dar"))
diff --git a/tests/merge/test_triggers.py b/tests/merge/test_triggers.py
index c3c7b493a..d5c4020b2 100644
--- a/tests/merge/test_triggers.py
+++ b/tests/merge/test_triggers.py
@@ -25,7 +25,7 @@ def _render_msg(func, msg, *args, **kwargs):
def make_fake_reporter(**kwargs):
- kwargs = dict((key, partial(_render_msg, val)) for key, val in kwargs.items())
+ kwargs = {key: partial(_render_msg, val) for key, val in kwargs.items()}
return fake_reporter(**kwargs)
@@ -260,9 +260,7 @@ class Test_ldconfig(trigger_mixin):
assert (tmp_path / "etc/ld.so.conf").exists()
# test normal functioning.
- (tmp_path / "etc/ld.so.conf").write_text(
- "\n".join(("/foon", "dar", "blarnsball", "#comment"))
- )
+ (tmp_path / "etc/ld.so.conf").write_text("/foon\ndar\nblarnsball\n#comment")
assert set(self.trigger.read_ld_so_conf(str(tmp_path))) == {
str(tmp_path / x) for x in ("foon", "dar", "blarnsball")
}
diff --git a/tests/package/test_base.py b/tests/package/test_base.py
index f366d5228..4678c6c10 100644
--- a/tests/package/test_base.py
+++ b/tests/package/test_base.py
@@ -22,7 +22,7 @@ class mixin:
def test_setattr(self):
with pytest.raises(AttributeError):
- setattr(self.mk_inst(), "asdf", 1)
+ self.mk_inst().asdf = 1
def test_delattr(self):
with pytest.raises(AttributeError):
diff --git a/tests/package/test_mutated.py b/tests/package/test_mutated.py
index 45f7c8109..35f04b504 100644
--- a/tests/package/test_mutated.py
+++ b/tests/package/test_mutated.py
@@ -48,7 +48,7 @@ class TestMutatedPkg:
for lpkg in (pkg1, mpkg1):
assert lpkg < mpkg2
assert mpkg2 > lpkg
- assert mpkg1 == mpkg1
+ assert mpkg1 == mpkg1 # noqa: PLR0124
assert pkg1 == mpkg1
def test_getattr(self):
@@ -56,4 +56,4 @@ class TestMutatedPkg:
assert MutatedPkg(pkg, {}).a == 1
assert MutatedPkg(pkg, {"a": 2}).a == 2
with pytest.raises(AttributeError):
- getattr(MutatedPkg(pkg, {}), "b")
+ _ = MutatedPkg(pkg, {}).b
diff --git a/tests/repository/test_multiplex.py b/tests/repository/test_multiplex.py
index 5977241dd..241de7af0 100644
--- a/tests/repository/test_multiplex.py
+++ b/tests/repository/test_multiplex.py
@@ -56,7 +56,7 @@ class TestMultiplex:
]
def test_sorting(self):
- assert list(
+ assert [
x.cpvstr
for x in self.ctree.itermatch(packages.AlwaysTrue, sorter=rev_sorted)
- ) == rev_sorted(self.tree1_list + self.tree2_list)
+ ] == rev_sorted(self.tree1_list + self.tree2_list)
diff --git a/tests/repository/test_prototype.py b/tests/repository/test_prototype.py
index 0c95dfdc1..dce24437e 100644
--- a/tests/repository/test_prototype.py
+++ b/tests/repository/test_prototype.py
@@ -62,11 +62,11 @@ class TestPrototype:
with pytest.raises(TypeError):
self.repo.match("asdf")
rc = packages.PackageRestriction("category", values.StrExactMatch("dev-util"))
- assert sorted(set(x.package for x in self.repo.itermatch(rc))) == sorted(
+ assert sorted({x.package for x in self.repo.itermatch(rc)}) == sorted(
["diffball", "bsdiff"]
)
rp = packages.PackageRestriction("package", values.StrExactMatch("diffball"))
- assert list(x.version for x in self.repo.itermatch(rp, sorter=sorted)) == [
+ assert [x.version for x in self.repo.itermatch(rp, sorter=sorted)] == [
"0.7",
"1.0",
]
diff --git a/tests/resolver/test_choice_point.py b/tests/resolver/test_choice_point.py
index 83b5e0642..946b55c30 100644
--- a/tests/resolver/test_choice_point.py
+++ b/tests/resolver/test_choice_point.py
@@ -64,7 +64,7 @@ class TestChoicePoint:
assert c.pdepend == [["or3"]]
c.reduce_atoms("or3")
with pytest.raises(IndexError):
- c.depend
+ _ = c.depend
def test_current_pkg(self):
c = self.gen_choice_point()
@@ -84,11 +84,11 @@ class TestChoicePoint:
c = self.gen_choice_point()
c.reduce_atoms("anddep1")
with pytest.raises(IndexError):
- c.depend
+ _ = c.depend
with pytest.raises(IndexError):
- c.rdepend
+ _ = c.rdepend
with pytest.raises(IndexError):
- c.pdepend
+ _ = c.pdepend
def test_nonzero(self):
c = self.gen_choice_point()
diff --git a/tests/resolver/test_pigeonholes.py b/tests/resolver/test_pigeonholes.py
index 71ee494d5..3d9ff5a51 100644
--- a/tests/resolver/test_pigeonholes.py
+++ b/tests/resolver/test_pigeonholes.py
@@ -7,7 +7,7 @@ from .test_choice_point import fake_package
class fake_blocker(restriction.base):
- __slots__ = ("key", "blocks")
+ __slots__ = ("blocks", "key")
def __init__(self, key, blocks=()):
restriction.base.__init__(self)
diff --git a/tests/restrictions/test_boolean.py b/tests/restrictions/test_boolean.py
index 72c62660f..533b464a5 100644
--- a/tests/restrictions/test_boolean.py
+++ b/tests/restrictions/test_boolean.py
@@ -94,7 +94,7 @@ class TestAndRestriction(base):
true, true, boolean.OrRestriction(false, true)
).dnf_solutions(),
)
- ) == [set([true, true, false]), set([true, true, true])]
+ ) == [{true, true, false}, {true, true, true}]
assert self.kls().dnf_solutions() == [[]]
def test_cnf_solutions(self):
@@ -106,7 +106,7 @@ class TestAndRestriction(base):
]
assert list(
self.kls(true, true, boolean.OrRestriction(false, true)).cnf_solutions()
- ) == list([[true], [true], [false, true]])
+ ) == [[true], [true], [false, true]]
assert not self.kls().cnf_solutions()
@@ -122,7 +122,7 @@ class TestOrRestriction(base):
def test_negate_match(self):
for x in ((true, false), (false, true), (true, true)):
- assert not self.kls(node_type="foo", negate=True, *x).match(None)
+ assert not self.kls(*x, node_type="foo", negate=True).match(None)
assert self.kls(false, false, node_type="foo", negate=True).match(None)
def test_dnf_solutions(self):
@@ -149,18 +149,20 @@ class TestOrRestriction(base):
for x in self.kls(
true, true, boolean.AndRestriction(false, true)
).cnf_solutions()
- ] == [set(x) for x in [[true, false], [true, true]]]
+ ] == [{true, false}, {true, true}]
assert [
set(x)
for x in self.kls(
self.kls(true, true, boolean.AndRestriction(false, true))
).cnf_solutions()
- ] == [set(x) for x in [[true, false], [true, true]]]
+ ] == [{true, false}, {true, true}]
- assert set(self.kls(self.kls(true, false), true).cnf_solutions()[0]) == set(
- [true, false, true]
- )
+ assert set(self.kls(self.kls(true, false), true).cnf_solutions()[0]) == {
+ true,
+ false,
+ true,
+ }
assert not self.kls().cnf_solutions()
diff --git a/tests/restrictions/test_delegated.py b/tests/restrictions/test_delegated.py
index 7aa964b13..3cfecd826 100644
--- a/tests/restrictions/test_delegated.py
+++ b/tests/restrictions/test_delegated.py
@@ -21,12 +21,6 @@ class Test_delegate(TestRestriction):
return y
for negated in (False, True):
-
- def assertIt(got, expected):
- assert got == expected, (
- f"got={got!r}, expected={expected!r}, negate={negated!r}"
- )
-
y = True
l[:] = []
o = self.kls(f, negate=negated)
@@ -36,29 +30,23 @@ class Test_delegate(TestRestriction):
self.assertNotMatches(o, [None], negated=negated)
if negated:
- assertIt(
- l,
- [
- "match",
- "force_False",
- "force_True",
- "match",
- "force_False",
- "force_True",
- ],
- )
+ assert l == [
+ "match",
+ "force_False",
+ "force_True",
+ "match",
+ "force_False",
+ "force_True",
+ ]
else:
- assertIt(
- l,
- [
- "match",
- "force_True",
- "force_False",
- "match",
- "force_True",
- "force_False",
- ],
- )
+ assert l == [
+ "match",
+ "force_True",
+ "force_False",
+ "match",
+ "force_True",
+ "force_False",
+ ]
def test_caching(self):
def f(*args):
diff --git a/tests/restrictions/test_values.py b/tests/restrictions/test_values.py
index 4a822d539..bd6a01d92 100644
--- a/tests/restrictions/test_values.py
+++ b/tests/restrictions/test_values.py
@@ -366,7 +366,7 @@ class TestFlatteningRestriction:
inst = values.FlatteningRestriction(
tuple, values.AnyMatch(values.EqualityMatch(None)), negate=negate
)
- assert not negate == inst.match([7, 8, [9, None]])
+ assert negate != inst.match([7, 8, [9, None]])
assert negate == inst.match([7, 8, (9, None)])
# Just check this does not raise
assert str(inst)
@@ -384,7 +384,7 @@ class TestFunctionRestriction:
yes_restrict = values.FunctionRestriction(yes, negate=negate)
no_restrict = values.FunctionRestriction(no, negate=negate)
- assert not negate == yes_restrict.match(7)
+ assert negate != yes_restrict.match(7)
assert negate == no_restrict.match(7)
for restrict in yes_restrict, no_restrict:
# Just check this does not raise
diff --git a/tests/scripts/test_pmaint.py b/tests/scripts/test_pmaint.py
index 09534654d..6ff2c5500 100644
--- a/tests/scripts/test_pmaint.py
+++ b/tests/scripts/test_pmaint.py
@@ -189,7 +189,7 @@ class TestCopy(ArgParseMixin):
return ret, config, out
def test_normal_function(self):
- ret, config, out = self.execute_main(
+ ret, config, _out = self.execute_main(
"fake_binpkg",
"--source-repo",
"fake_vdb",
@@ -206,7 +206,7 @@ class TestCopy(ArgParseMixin):
)
d = {"sys-apps": {"portage": ["2.1", "2.2"]}}
- ret, config, out = self.execute_main(
+ ret, config, _out = self.execute_main(
"fake_binpkg",
"--source-repo",
"fake_vdb",
@@ -222,7 +222,7 @@ class TestCopy(ArgParseMixin):
)
def test_ignore_existing(self):
- ret, config, out = self.execute_main(
+ ret, config, _out = self.execute_main(
"fake_binpkg",
"--source-repo",
"fake_vdb",
@@ -239,7 +239,7 @@ class TestCopy(ArgParseMixin):
"uninstalled should be the same as replaced; empty"
)
- ret, config, out = self.execute_main(
+ ret, config, _out = self.execute_main(
"fake_binpkg",
"--source-repo",
"fake_vdb",
diff --git a/tests/sync/test_base.py b/tests/sync/test_base.py
index 489d87319..2e956ea40 100644
--- a/tests/sync/test_base.py
+++ b/tests/sync/test_base.py
@@ -40,15 +40,15 @@ class TestSyncer:
@mock.patch("snakeoil.process.spawn.spawn")
def test_usersync_disabled(self, spawn):
o = base.Syncer(self.repo_path, "http://foo/bar.git", usersync=False)
- o.uid == os_data.uid
- o.gid == os_data.gid
+ assert o.uid == os_data.uid
+ assert o.gid == os_data.gid
@mock.patch("snakeoil.process.spawn.spawn")
def test_usersync_portage_perms(self, spawn):
# sync uses portage perms if repo dir doesn't exist
o = base.Syncer(self.repo_path, "http://foo/bar.git", usersync=True)
- o.uid == os_data.portage_uid
- o.gid == os_data.portage_gid
+ assert o.uid == os_data.portage_uid
+ assert o.gid == os_data.portage_gid
@mock.patch("snakeoil.process.spawn.spawn")
def test_usersync_repo_dir_perms(self, spawn):
@@ -106,10 +106,9 @@ class TestExternalSyncer:
class TestVcsSyncer:
def test_basedir_perms_error(self, spawn, find_binary, tmp_path):
syncer = git.git_syncer(str(tmp_path), "git://blah.git")
- with pytest.raises(base.PathError):
- with mock.patch("os.stat") as stat:
- stat.side_effect = EnvironmentError("fake exception")
- syncer.sync()
+ with pytest.raises(base.PathError), mock.patch("os.stat") as stat:
+ stat.side_effect = OSError("fake exception")
+ syncer.sync()
def test_basedir_is_file_error(self, spawn, find_binary, tmp_path):
repo = tmp_path / "repo"
diff --git a/tests/sync/test_bzr.py b/tests/sync/test_bzr.py
index e92996595..330458e2d 100644
--- a/tests/sync/test_bzr.py
+++ b/tests/sync/test_bzr.py
@@ -27,4 +27,4 @@ class TestBzrSyncer:
with mock.patch("snakeoil.process.find_binary") as find_binary:
find_binary.return_value = "bzr"
o = bzr.bzr_syncer(str(self.repo_path), "bzr+http://dar")
- o.uri == "http://dar"
+ assert o.uri == "http://dar"
diff --git a/tests/sync/test_git_svn.py b/tests/sync/test_git_svn.py
index 50e8a2be3..53d77591d 100644
--- a/tests/sync/test_git_svn.py
+++ b/tests/sync/test_git_svn.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
from unittest import mock
import pytest