commit:     c5aee4dced6c2c9f9d44e52ed12dbbfedae4de10
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 15:23:14 2026 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Jan  3 15:23:14 2026 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c5aee4dc

add ruff linter & fix

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 .github/workflows/test.yml            | 12 ++++++++++++
 examples/changed_use.py               |  1 -
 pyproject.toml                        |  5 +++++
 src/pkgcore/binpkg/repository.py      |  3 +--
 src/pkgcore/cache/__init__.py         |  5 ++---
 src/pkgcore/cache/flat_hash.py        |  6 +++---
 src/pkgcore/ebuild/domain.py          |  1 -
 src/pkgcore/ebuild/eapi.py            |  6 +++---
 src/pkgcore/ebuild/ebd.py             |  2 +-
 src/pkgcore/ebuild/formatter.py       |  6 +++---
 src/pkgcore/ebuild/inspect_profile.py |  4 +++-
 src/pkgcore/ebuild/misc.py            | 16 ++++++++--------
 src/pkgcore/ebuild/pkg_updates.py     |  2 +-
 src/pkgcore/ebuild/repository.py      |  2 +-
 src/pkgcore/fs/livefs.py              |  5 ++++-
 src/pkgcore/fs/ops.py                 | 14 +++++++++-----
 src/pkgcore/merge/engine.py           |  2 +-
 src/pkgcore/merge/triggers.py         |  4 +++-
 src/pkgcore/operations/__init__.py    |  4 +++-
 src/pkgcore/operations/domain.py      |  1 -
 src/pkgcore/pkgsets/glsa.py           |  9 +++++++--
 src/pkgcore/repository/prototype.py   |  6 ++++--
 src/pkgcore/repository/util.py        |  9 +++++++--
 src/pkgcore/resolver/plan.py          |  2 +-
 src/pkgcore/resolver/state.py         |  4 ++--
 src/pkgcore/resolver/util.py          |  5 ++++-
 src/pkgcore/restrictions/boolean.py   |  9 +++++++--
 src/pkgcore/restrictions/util.py      |  2 +-
 src/pkgcore/scripts/pmaint.py         |  2 +-
 src/pkgcore/scripts/pquery.py         |  4 ++--
 src/pkgcore/sync/http.py              |  5 +++--
 src/pkgcore/util/thread_pool.py       |  2 +-
 src/pkgcore/vdb/repo_ops.py           |  1 -
 tests/ebuild/test_atom.py             |  4 ++--
 tests/ebuild/test_conditionals.py     |  2 +-
 tests/ebuild/test_domain.py           |  1 -
 tests/ebuild/test_eapi.py             |  2 +-
 tests/ebuild/test_ebuild_src.py       |  2 +-
 tests/ebuild/test_profiles.py         | 10 ++--------
 tests/ebuild/test_repo_objs.py        |  2 +-
 tests/fetch/test_base.py              | 17 +++++++++--------
 tests/scripts/test_pmaint.py          |  1 -
 tests/sync/test_base.py               | 12 ++++++------
 tests/sync/test_cvs.py                |  4 ++--
 tests/sync/test_rsync.py              |  2 +-
 tests/util/test_parserestrict.py      |  2 +-
 46 files changed, 130 insertions(+), 92 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index d6645b34..3083f049 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -140,6 +140,18 @@ jobs:
         PY_COLORS: 1 # forcibly enable pytest colors
       run: pytest -v
 
+  lint:
+    runs-on: ubuntu-latest
+    if: inputs.disable-format-check == ''
+    steps:
+    - name: Checkout pkgcore
+      uses: actions/checkout@v5
+
+    - name: Ruff lint check
+      uses: astral-sh/ruff-action@v3
+      with:
+        args: "check --diff"
+
   format:
     runs-on: ubuntu-latest
     if: inputs.disable-format-check == ''

diff --git a/examples/changed_use.py b/examples/changed_use.py
index 4623dde1..d5d8fc9a 100755
--- a/examples/changed_use.py
+++ b/examples/changed_use.py
@@ -1,7 +1,6 @@
 #!/usr/bin/env python3
 # Copyright 2007 Charlie Shepherd
 
-import os
 import sys
 from operator import attrgetter
 

diff --git a/pyproject.toml b/pyproject.toml
index 4cae5d7c..cbd21235 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -90,5 +90,10 @@ markers = [
        "net: tests that require network access (must enable --network option 
to run)",
 ]
 
+[tool.ruff]
+target-version = "py311"
 [tool.ruff.lint]
 extend-select = ["I"]
+ignore = [
+       "E741",  # ambiguous variable name
+]

diff --git a/src/pkgcore/binpkg/repository.py b/src/pkgcore/binpkg/repository.py
index ee0b2e4d..aeee9089 100644
--- a/src/pkgcore/binpkg/repository.py
+++ b/src/pkgcore/binpkg/repository.py
@@ -83,7 +83,7 @@ class BinPkg(ebuild_built.generate_new_factory):
             t = force_unpacking(op_inst.format_op)
             t.register(engine_inst)
 
-        klass._add_format_triggers(self, pkg, op_inst, format_op_inst, 
engine_inst)
+        super()._add_format_triggers(self, pkg, op_inst, format_op_inst, 
engine_inst)
 
     def scan_contents(self, location):
         return scan(location, offset=location)
@@ -251,7 +251,6 @@ class tree(prototype.tree):
         l = set()
         d = {}
         lext = len(self.extension)
-        bad = False
         try:
             for x in listdir_files(cpath):
                 # don't use lstat; symlinks may exist

diff --git a/src/pkgcore/cache/__init__.py b/src/pkgcore/cache/__init__.py
index 798841b2..7fde50b4 100644
--- a/src/pkgcore/cache/__init__.py
+++ b/src/pkgcore/cache/__init__.py
@@ -227,16 +227,15 @@ class base:
         for (chf, convert), item in data:
             yield chf, convert(item)
 
-    def reconstruct_eclasses(self, cpv, eclass_string):
+    def reconstruct_eclasses(self, cpv, eclass_string: str):
         """Turn a string from :obj:`serialize_eclasses` into a dict."""
         if not isinstance(eclass_string, str):
-            raise TypeError("eclass_string must be basestring, got %r" % 
eclass_string)
+            raise TypeError(f"eclass_string must be basestring, got 
{eclass_string!r}")
         eclass_data = eclass_string.strip().split(self.eclass_splitter)
         if eclass_data == [""]:
             # occasionally this occurs in the fs backends.  they suck.
             return []
 
-        l = len(eclass_data)
         chf_funcs = self.eclass_chf_deserializers
         tuple_len = len(chf_funcs) + 1
         if len(eclass_data) % tuple_len:

diff --git a/src/pkgcore/cache/flat_hash.py b/src/pkgcore/cache/flat_hash.py
index fd00bf50..e8d31703 100644
--- a/src/pkgcore/cache/flat_hash.py
+++ b/src/pkgcore/cache/flat_hash.py
@@ -124,8 +124,8 @@ class database(fs_template.FsBased):
             except FileNotFoundError:
                 continue
             except EnvironmentError as e:
-                raise KeyError(cpv, f"access failure: {e}")
-            for l in os.listdir(d):
+                raise KeyError(d, f"access failure: {e}") from e
+            for l in subdirs:
                 if l.endswith(".cpickle"):
                     continue
                 p = pjoin(d, l)
@@ -134,7 +134,7 @@ class database(fs_template.FsBased):
                 except FileNotFoundError:
                     continue
                 except EnvironmentError as e:
-                    raise KeyError(cpv, f"Unhandled IO error: {e}")
+                    raise KeyError(d, f"Unhandled IO error: {e}") from e
                 if stat.S_ISDIR(st.st_mode):
                     dirs.append(p)
                     continue

diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py
index 426ac0ec..98b02d60 100644
--- a/src/pkgcore/ebuild/domain.py
+++ b/src/pkgcore/ebuild/domain.py
@@ -41,7 +41,6 @@ from ..repository.util import RepositoryGroup
 from ..restrictions import packages, values
 from ..restrictions.delegated import delegate
 from ..util.parserestrict import ParseError, parse_match
-from . import const
 from . import repository as ebuild_repo
 from .atom import atom as _atom
 from .eapi import get_latest_PMS_eapi

diff --git a/src/pkgcore/ebuild/eapi.py b/src/pkgcore/ebuild/eapi.py
index de8c548b..b5bd137f 100644
--- a/src/pkgcore/ebuild/eapi.py
+++ b/src/pkgcore/ebuild/eapi.py
@@ -14,6 +14,9 @@ from snakeoil.mappings import ImmutableDict, 
OrderedFrozenSet, inject_getitem_as
 from snakeoil.process.spawn import bash_version
 from snakeoil.sequences import unique_stable
 
+from ..log import logger
+from . import atom, const
+
 LATEST_PMS_EAPI_VER = "9"
 
 
@@ -22,9 +25,6 @@ def get_latest_PMS_eapi():
     return get_eapi(LATEST_PMS_EAPI_VER)
 
 
-from ..log import logger
-from . import atom, const
-
 _valid_EAPI_regex = regexp(r"^[A-Za-z0-9_][A-Za-z0-9+_.-]*$")
 _valid_use_flag = regexp(r"^[A-Za-z0-9][A-Za-z0-9+_@-]*$")
 

diff --git a/src/pkgcore/ebuild/ebd.py b/src/pkgcore/ebuild/ebd.py
index 6fb4fc83..113777ec 100644
--- a/src/pkgcore/ebuild/ebd.py
+++ b/src/pkgcore/ebuild/ebd.py
@@ -139,7 +139,7 @@ class ebd:
         self.restrict = pkg.restrict
 
         for x in ("sandbox", "userpriv"):
-            setattr(self, x, self.feat_or_bool(x) and not (x in self.restrict))
+            setattr(self, x, self.feat_or_bool(x) and x not in self.restrict)
         if self.userpriv and os.getuid() != 0:
             self.userpriv = False
 

diff --git a/src/pkgcore/ebuild/formatter.py b/src/pkgcore/ebuild/formatter.py
index 11a42232..6bc5c1d3 100644
--- a/src/pkgcore/ebuild/formatter.py
+++ b/src/pkgcore/ebuild/formatter.py
@@ -81,7 +81,7 @@ class use_expand_filter:
                 usel.append(flag)
             elif data:
                 # non hidden flag.
-                if not data[0] in ue_dict:
+                if data[0] not in ue_dict:
                     ue_dict[data[0]] = set([data[1]])
                 else:
                     ue_dict[data[0]].add(data[1])
@@ -369,8 +369,8 @@ class PortageFormatter(CountingFormatter):
             try:
                 sorter = op.pkg.repo.use_expand_sorter(expand)
             except AttributeError:
-                # TODO: hack for unit tests using fake repo objs
-                sorter = lambda k: k
+                # TODO: hack for unit tests using fake repo objs, use identity
+                sorter = None
             flaglists = [sorted(d.get(expand, ()), key=sorter) for d in 
usedicts]
             self.format_use(expand, *flaglists, sorter=sorter)
 

diff --git a/src/pkgcore/ebuild/inspect_profile.py 
b/src/pkgcore/ebuild/inspect_profile.py
index ede5fd88..0b6be6f8 100644
--- a/src/pkgcore/ebuild/inspect_profile.py
+++ b/src/pkgcore/ebuild/inspect_profile.py
@@ -326,7 +326,9 @@ class defaults(_base, metaclass=_register_command):
         if var_filter:
             var_filter = set(var_filter).__contains__
         else:
-            var_filter = lambda x: True
+
+            def var_filter(x):
+                return True
 
         settings = namespace.profile.default_env
         vars = sorted(filter(var_filter, settings))

diff --git a/src/pkgcore/ebuild/misc.py b/src/pkgcore/ebuild/misc.py
index 84a8a547..f19a8269 100644
--- a/src/pkgcore/ebuild/misc.py
+++ b/src/pkgcore/ebuild/misc.py
@@ -246,8 +246,8 @@ class collapsed_restrict_to_data(GenericEquality):
             for restrict, data in specific:
                 if restrict.match(pkg):
                     l.append(data)
-        for atom, data in self.atoms.get(pkg.key, ()):
-            if atom.match(pkg):
+        for a, data in self.atoms.get(pkg.key, ()):
+            if a.match(pkg):
                 l.append(data)
 
         if pre_defaults:
@@ -270,8 +270,8 @@ class collapsed_restrict_to_data(GenericEquality):
                 if restrict.match(pkg):
                     for item in data:
                         yield item
-        for atom, data in self.atoms.get(pkg.key, ()):
-            if atom.match(pkg):
+        for a, data in self.atoms.get(pkg.key, ()):
+            if a.match(pkg):
                 for item in data:
                     yield item
 
@@ -283,8 +283,8 @@ class 
non_incremental_collapsed_restrict_to_data(collapsed_restrict_to_data):
             for restrict, data in specific:
                 if restrict.match(pkg):
                     l.append(data)
-        for atom, data in self.atoms.get(pkg.key, ()):
-            if atom.match(pkg):
+        for a, data in self.atoms.get(pkg.key, ()):
+            if a.match(pkg):
                 l.append(data)
         if not l:
             if force_copy:
@@ -298,8 +298,8 @@ class 
non_incremental_collapsed_restrict_to_data(collapsed_restrict_to_data):
         l = [self.defaults]
         for specific in self.freeform:
             l.extend(data for restrict, data in specific if 
restrict.match(pkg))
-        for atom, data in self.atoms.get(pkg.key, ()):
-            if atom.match(pkg):
+        for a, data in self.atoms.get(pkg.key, ()):
+            if a.match(pkg):
                 l.append(data)
         if len(l) == 1:
             return iter(self.defaults)

diff --git a/src/pkgcore/ebuild/pkg_updates.py 
b/src/pkgcore/ebuild/pkg_updates.py
index c1f64195..fe498489 100644
--- a/src/pkgcore/ebuild/pkg_updates.py
+++ b/src/pkgcore/ebuild/pkg_updates.py
@@ -121,7 +121,7 @@ def _process_updates(sequence, filename, mods, moved):
                 continue
 
             src_slot = atom(f"{src}:{line[2]}")
-            trg_slot = atom(f"{src.key}:{line[3]}")
+            _ = atom(f"{src.key}:{line[3]}")
 
             mods[src.key][1].append(("slotmove", src_slot, line[3]))
         else:

diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py
index 3290caf5..4cb8363a 100644
--- a/src/pkgcore/ebuild/repository.py
+++ b/src/pkgcore/ebuild/repository.py
@@ -801,7 +801,7 @@ class _RegenOpHelper:
     def __call__(self, pkg):
         try:
             return pkg._fetch_metadata(ebp=self.ebp, force_regen=self.force)
-        except pkg_errors.MetadataException as e:
+        except pkg_errors.MetadataException:
             # ebuild processor is dead, so force a replacement request
             self.ebp = self.request_ebp()
             raise

diff --git a/src/pkgcore/fs/livefs.py b/src/pkgcore/fs/livefs.py
index a0930a4b..538b7e87 100644
--- a/src/pkgcore/fs/livefs.py
+++ b/src/pkgcore/fs/livefs.py
@@ -248,7 +248,10 @@ def intersect(cset, realpath=False):
     if realpath:
         f2 = _realpath_dir()
     else:
-        f2 = lambda x: x
+
+        def f2(x):
+            return x
+
     for x in cset:
         try:
             yield f(f2(x.location))

diff --git a/src/pkgcore/fs/ops.py b/src/pkgcore/fs/ops.py
index b4e1506c..a305253c 100644
--- a/src/pkgcore/fs/ops.py
+++ b/src/pkgcore/fs/ops.py
@@ -187,9 +187,9 @@ def do_link(src, trg):
         return False
     try:
         os.rename(path, trg.location)
-    except EnvironmentError:
+    except EnvironmentError as e:
         unlink_if_exists(path)
-        if e.eerrno != errno.EXDEV:
+        if e.errno != errno.EXDEV:
             # weird error, broken FS codes, perms, or someone is screwing with 
us.
             raise
         # this is only possible on overlay fs's; while annoying, you can have 
two
@@ -211,7 +211,9 @@ def merge_contents(cset, offset=None, callback=None):
     """
 
     if callback is None:
-        callback = lambda obj: None
+
+        def callback(obj):
+            return None
 
     if not isinstance(cset, contents.contentsSet):
         raise TypeError(f"cset must be a contentsSet, got {cset!r}")
@@ -306,7 +308,9 @@ def unmerge_contents(cset, offset=None, callback=None):
     """
 
     if callback is None:
-        callback = lambda obj: None
+
+        def callback(obj):
+            return None
 
     iterate = iter
     if offset is not None:
@@ -323,7 +327,7 @@ def unmerge_contents(cset, offset=None, callback=None):
         try:
             os.rmdir(x.location)
         except OSError as e:
-            if not e.errno in (
+            if e.errno not in (
                 errno.ENOTEMPTY,
                 errno.ENOENT,
                 errno.ENOTDIR,

diff --git a/src/pkgcore/merge/engine.py b/src/pkgcore/merge/engine.py
index 08c73ebb..f964be90 100644
--- a/src/pkgcore/merge/engine.py
+++ b/src/pkgcore/merge/engine.py
@@ -355,7 +355,7 @@ class MergeEngine:
                             f"modification error occurred during trigger 
{trigger!r}: {e}"
                         )
                         raise
-                    except Exception as e:
+                    except Exception:
                         if not trigger.suppress_exceptions:
                             raise
 

diff --git a/src/pkgcore/merge/triggers.py b/src/pkgcore/merge/triggers.py
index 97f97311..c0f58a25 100644
--- a/src/pkgcore/merge/triggers.py
+++ b/src/pkgcore/merge/triggers.py
@@ -621,7 +621,9 @@ class BlockFileType(base):
         file_typer = file_type.file_identifier()
 
         if self.filter_regex is None:
-            filter_re = lambda x: True
+
+            def filter_re(x):
+                return True
         else:
             filter_re = re.compile(self.filter_regex).match
         bad_pat = re.compile(self.bad_regex).match

diff --git a/src/pkgcore/operations/__init__.py 
b/src/pkgcore/operations/__init__.py
index e1d18813..b939577b 100644
--- a/src/pkgcore/operations/__init__.py
+++ b/src/pkgcore/operations/__init__.py
@@ -82,7 +82,9 @@ class base:
     def _setup_api(self):
         recast_exc = self.__casting_exception__
         if recast_exc is None:
-            f = lambda x, y: x
+
+            def f(x, y):
+                return x
         else:
             f = self._wrap_exception
         for op in self.enabled_operations:

diff --git a/src/pkgcore/operations/domain.py b/src/pkgcore/operations/domain.py
index 41a24ac0..73eea3a6 100644
--- a/src/pkgcore/operations/domain.py
+++ b/src/pkgcore/operations/domain.py
@@ -12,7 +12,6 @@ from snakeoil.dependant_methods import ForcedDepends
 
 from ..exceptions import PkgcoreException
 from ..log import logger
-from ..merge import errors as merge_errors
 from ..merge.engine import MergeEngine
 from ..package.mutated import MutatedPkg
 

diff --git a/src/pkgcore/pkgsets/glsa.py b/src/pkgcore/pkgsets/glsa.py
index d8b092aa..6499ad92 100644
--- a/src/pkgcore/pkgsets/glsa.py
+++ b/src/pkgcore/pkgsets/glsa.py
@@ -214,13 +214,18 @@ def find_vulnerable_repo_pkgs(glsa_src, repo, 
grouped=False, arch=None):
 
     i = glsa_src.pkg_grouped_iter() if grouped else iter(glsa_src)
     if arch is None:
-        wrapper = lambda p: p
+
+        def wrapper(p):
+            return p
     else:
         if isinstance(arch, str):
             arch = (arch,)
         else:
             arch = tuple(arch)
-        wrapper = lambda p: mutated.MutatedPkg(p, {"keywords": arch})
+
+        def wrapper(p):
+            return mutated.MutatedPkg(p, {"keywords": arch})
+
     for restrict in i:
         matches = caching_iter(
             wrapper(x) for x in repo.itermatch(restrict, sorter=sorted)

diff --git a/src/pkgcore/repository/prototype.py 
b/src/pkgcore/repository/prototype.py
index 2c8cf5df..fa38e07a 100644
--- a/src/pkgcore/repository/prototype.py
+++ b/src/pkgcore/repository/prototype.py
@@ -8,7 +8,7 @@ import typing
 from pathlib import Path
 
 from snakeoil.klass import jit_attr
-from snakeoil.mappings import DictMixin, LazyValDict
+from snakeoil.mappings import DictMixin
 from snakeoil.sequences import iflatten_instance
 
 from ..ebuild.atom import atom
@@ -260,7 +260,9 @@ class tree:
             if versioned:
                 raw_pkg_cls = self.package_class
             else:
-                raw_pkg_cls = lambda *args: args
+
+                def raw_pkg_cls(*args):
+                    return args
 
         if isinstance(restrict, atom):
             candidates = [(restrict.category, restrict.package)]

diff --git a/src/pkgcore/repository/util.py b/src/pkgcore/repository/util.py
index 7b28992c..398df077 100644
--- a/src/pkgcore/repository/util.py
+++ b/src/pkgcore/repository/util.py
@@ -90,11 +90,16 @@ class RepositoryGroup(DictMixin):
 
     def __getitem__(self, key):
         if isinstance(key, str):
-            func = lambda x: key in x.aliases
+
+            def func(x):
+                return key in x.aliases
         elif isinstance(key, int):
             return self.repos[key]
         else:
-            func = lambda x: key == x
+
+            def func(x):
+                return key == x
+
         try:
             return next(filter(func, self.repos))
         except StopIteration:

diff --git a/src/pkgcore/resolver/plan.py b/src/pkgcore/resolver/plan.py
index 1e78f988..aa8ec273 100644
--- a/src/pkgcore/resolver/plan.py
+++ b/src/pkgcore/resolver/plan.py
@@ -695,7 +695,7 @@ class merge_plan:
             self.insoluble.add(atom)
         if ret is not None:
             self.notify_viable(stack, atom, *ret[0], **ret[1])
-            if ret[0][0] == True:
+            if ret[0][0] is True:
                 state.add_backref_op(choices, 
choices.current_pkg).apply(self.state)
                 return True
             return None

diff --git a/src/pkgcore/resolver/state.py b/src/pkgcore/resolver/state.py
index a297981a..807de45a 100644
--- a/src/pkgcore/resolver/state.py
+++ b/src/pkgcore/resolver/state.py
@@ -129,10 +129,10 @@ class base_op_state:
         )
 
     def apply(self, plan):
-        raise NotImplemented(self, "apply")
+        raise NotImplementedError(self, "apply")
 
     def revert(self, plan):
-        raise NotImplemented(self, "revert")
+        raise NotImplementedError(self, "revert")
 
 
 class add_op(base_op_state):

diff --git a/src/pkgcore/resolver/util.py b/src/pkgcore/resolver/util.py
index 37583da7..726b2b64 100644
--- a/src/pkgcore/resolver/util.py
+++ b/src/pkgcore/resolver/util.py
@@ -7,7 +7,10 @@ __all__ = (
 
 def group_attempts(sequence, filter_func=None):
     if filter_func is None:
-        filter_func = lambda x: True
+
+        def filter_func(x):
+            return True
+
     last, l = None, []
     for x in sequence:
         if isinstance(x, tuple) and x[0] == "inspecting":

diff --git a/src/pkgcore/restrictions/boolean.py 
b/src/pkgcore/restrictions/boolean.py
index 9d61ffbf..ba0c7a76 100644
--- a/src/pkgcore/restrictions/boolean.py
+++ b/src/pkgcore/restrictions/boolean.py
@@ -200,9 +200,14 @@ def iterative_quad_toggling(
     kill_switch=None,
 ):
     if desired_false is None:
-        desired_false = lambda r, a: r.force_False(*a)
+
+        def desired_false(r, a):
+            return r.force_False(*a)
+
     if desired_true is None:
-        desired_true = lambda r, a: r.force_True(*a)
+
+        def desired_true(r, a):
+            return r.force_True(*a)
 
     reset = True
     if starting == 0:

diff --git a/src/pkgcore/restrictions/util.py b/src/pkgcore/restrictions/util.py
index 40674dda..b84f8dc9 100644
--- a/src/pkgcore/restrictions/util.py
+++ b/src/pkgcore/restrictions/util.py
@@ -4,7 +4,7 @@ restriction related utilities
 
 from snakeoil.sequences import iflatten_func
 
-from . import boolean, packages, restriction
+from . import boolean, restriction
 
 
 def _is_package_instance(inst):

diff --git a/src/pkgcore/scripts/pmaint.py b/src/pkgcore/scripts/pmaint.py
index f3d4bae9..c5c29b74 100644
--- a/src/pkgcore/scripts/pmaint.py
+++ b/src/pkgcore/scripts/pmaint.py
@@ -284,7 +284,7 @@ def update_pkg_desc_index(repo, observer):
                         versions = " ".join(x.fullver for x in cpvs)
                         f.write(f"{cat}/{pkg} {versions}: {desc}\n")
                         break
-                    except MetadataException as e:
+                    except MetadataException:
                         # should be caught and outputted already by cache regen
                         ret = 1
         f.close()

diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index 13c50596..2da71f05 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -1132,7 +1132,7 @@ output.add_argument(
     "--format",
     metavar="format",
     help="print this format filled with package attributes, suppresses other 
output",
-    docs=f"""
+    docs="""
         Use the given format string to print package attributes. The format
         uses standard Python format string syntax (see :ref:`formatspec` for
         details), with the all attributes of ``--attr``.
@@ -1167,7 +1167,7 @@ one_attr_mux.add_argument(
     choices=printable_attrs,
     metavar="attribute",
     help="print one attribute, suppresses other output",
-    docs=f"""
+    docs="""
         Print the given attribute's value, while suppressing all other output.
         All attributes of ``--attr`` are accepted.
     """,

diff --git a/src/pkgcore/sync/http.py b/src/pkgcore/sync/http.py
index da53a1fb..f0a94315 100644
--- a/src/pkgcore/sync/http.py
+++ b/src/pkgcore/sync/http.py
@@ -1,6 +1,5 @@
 __all__ = ("http_syncer",)
 
-import errno
 import os
 import ssl
 import sys
@@ -59,7 +58,9 @@ class http_syncer(base.Syncer):
 
         # Manually check cached values ourselves since some servers appear to
         # ignore If-None-Match or If-Modified-Since headers.
-        convert = lambda x: x.strip() if x else None
+        def convert(x):
+            return x.strip() if x else None
+
         etag = resp.getheader("ETag")
         modified = resp.getheader("Last-Modified")
         if not force:

diff --git a/src/pkgcore/util/thread_pool.py b/src/pkgcore/util/thread_pool.py
index 6141e02c..faf37a39 100644
--- a/src/pkgcore/util/thread_pool.py
+++ b/src/pkgcore/util/thread_pool.py
@@ -14,7 +14,7 @@ def reclaim_threads(threads):
             x.join()
         except IGNORED_EXCEPTIONS:
             raise
-        except Exception as e:
+        except Exception:
             # should do something better here
             pass
 

diff --git a/src/pkgcore/vdb/repo_ops.py b/src/pkgcore/vdb/repo_ops.py
index 8ec6bf8d..cd683bc1 100644
--- a/src/pkgcore/vdb/repo_ops.py
+++ b/src/pkgcore/vdb/repo_ops.py
@@ -13,7 +13,6 @@ from snakeoil.osutils import ensure_dirs
 from snakeoil.version import get_version
 
 from .. import __title__
-from ..ebuild import conditionals
 from ..log import logger
 from ..operations import repo as repo_ops
 from .contents import ContentsFile

diff --git a/tests/ebuild/test_atom.py b/tests/ebuild/test_atom.py
index cc953899..dbf30614 100644
--- a/tests/ebuild/test_atom.py
+++ b/tests/ebuild/test_atom.py
@@ -257,7 +257,7 @@ class TestAtom(TestRestriction):
         self.assertMatch(kls(f"{astr}[debug,-not]"), c)
         self.assertMatch(kls(f"{astr}:1[debug,-not]"), c)
 
-        for atom in (
+        for atom_str in (
             f"{astr}[]",
             f"{astr}[-]",
             "dev-util/diffball[foon",
@@ -277,7 +277,7 @@ class TestAtom(TestRestriction):
             "dev-util/diffball[!-x?]",
         ):
             with pytest.raises(errors.MalformedAtom):
-                kls(atom)
+                kls(atom_str)
 
     def test_slot(self):
         astr = "dev-util/confcache"

diff --git a/tests/ebuild/test_conditionals.py 
b/tests/ebuild/test_conditionals.py
index 79c1d181..f310f9c5 100644
--- a/tests/ebuild/test_conditionals.py
+++ b/tests/ebuild/test_conditionals.py
@@ -158,7 +158,7 @@ class TestDepSetParsing(base):
             v = depset.split()
         got = list(self.flatten_restricts(base.gen_depset(self, depset)))
         wanted = list(v)
-        assert got == v, "given {s!r}\nexpected {wanted!r} but got {got!r}"
+        assert got == v, f"given {depset!r}\nexpected {wanted!r} but got 
{got!r}"
 
     @pytest.mark.parametrize("depset", depsets)
     def test_depset_str(self, depset):

diff --git a/tests/ebuild/test_domain.py b/tests/ebuild/test_domain.py
index 15e243b4..cad022cb 100644
--- a/tests/ebuild/test_domain.py
+++ b/tests/ebuild/test_domain.py
@@ -1,4 +1,3 @@
-import textwrap
 from unittest import mock
 
 import pytest

diff --git a/tests/ebuild/test_eapi.py b/tests/ebuild/test_eapi.py
index d07aed10..03fd539d 100644
--- a/tests/ebuild/test_eapi.py
+++ b/tests/ebuild/test_eapi.py
@@ -35,7 +35,7 @@ class TestEAPI:
             # inadequate bash version
             bash_version.return_value = "3.1"
             with pytest.raises(SystemExit) as excinfo:
-                new_eapi = EAPI.register(magic="new", 
optionals={"bash_compat": "3.2"})
+                _ = EAPI.register(magic="new", optionals={"bash_compat": 
"3.2"})
             assert (
                 "EAPI 'new' requires >=bash-3.2, system version: 3.1"
                 == excinfo.value.args[0]

diff --git a/tests/ebuild/test_ebuild_src.py b/tests/ebuild/test_ebuild_src.py
index 58389dcb..50b27325 100644
--- a/tests/ebuild/test_ebuild_src.py
+++ b/tests/ebuild/test_ebuild_src.py
@@ -641,7 +641,7 @@ class TestPackageFactory:
         assert len(pf._cache) == 0
         assert sorted(pf.mirrors) == sorted(mirrors)
         assert pf.mirrors["gentoo"] == mirrors["gentoo"]
-        assert pf.default_mirrors == None
+        assert pf.default_mirrors is None
 
         def_mirrors = ["http://def1/";, "http://blah1/";]
         pf = self.mkinst(default_mirrors=def_mirrors)

diff --git a/tests/ebuild/test_profiles.py b/tests/ebuild/test_profiles.py
index c5686de8..197c297a 100644
--- a/tests/ebuild/test_profiles.py
+++ b/tests/ebuild/test_profiles.py
@@ -57,12 +57,6 @@ class profile_mixin:
             given_mapping.render_to_dict(), desired_mapping, f, chunked_data
         )
 
-    def assertEqualPayload(self, given_mapping, desired_mapping):
-        def f(chunk):
-            return chunked_data(chunk.restrict, tuple(sorted(chunk.data)))
-
-        return self._assertEqualPayload(given_mapping, desired_mapping, f, 
chunked_data)
-
     assertEqualPayload = assertEqualChunks
 
     def _assertEqualPayload(self, given_mapping, desired_mapping, reformat_f, 
bare_kls):
@@ -543,7 +537,7 @@ class TestPmsProfileNode(profile_mixin):
 
         # verify that use.force is layered first, then package.use.force
         self.write_file(tmp_path, "package.use.force", "dev-util/bar -mmx 
foon")
-        p = self.klass(path)
+        _ = self.klass(path)
         self.assertEqualChunks(
             self.klass(path).forced_use,
             {
@@ -634,7 +628,7 @@ class TestPmsProfileNode(profile_mixin):
 
         # verify that use.stable.force is layered first, then 
package.use.stable.force
         self.write_file(tmp_path, "package.use.stable.force", "dev-util/bar 
-mmx foon")
-        p = self.klass(path)
+        _ = self.klass(path)
         self.assertEqualChunks(
             self.klass(path).stable_forced_use,
             {

diff --git a/tests/ebuild/test_repo_objs.py b/tests/ebuild/test_repo_objs.py
index cd4335a7..3dd5d2e4 100644
--- a/tests/ebuild/test_repo_objs.py
+++ b/tests/ebuild/test_repo_objs.py
@@ -135,7 +135,7 @@ class TestMetadataXml:
 
     def test_longdesc(self):
         # empty...
-        assert None == self.get_metadata_xml().longdescription
+        assert self.get_metadata_xml().longdescription is None
         s = """
 I saw the best minds of my generation destroyed by madness, starving
 hysterical naked, dragging themselves throughout the negro streets at dawn

diff --git a/tests/fetch/test_base.py b/tests/fetch/test_base.py
index f7de8298..42d27750 100644
--- a/tests/fetch/test_base.py
+++ b/tests/fetch/test_base.py
@@ -4,6 +4,7 @@ from functools import partial
 import pytest
 from snakeoil import data_source
 from snakeoil.chksum import get_handlers
+from snakeoil.mappings import LazyValDict
 
 from pkgcore.fetch import base, errors, fetchable
 
@@ -12,9 +13,6 @@ data = repeating_str * 4000
 handlers = get_handlers()
 
 
-from snakeoil.mappings import LazyValDict
-
-
 def _callback(chf):
     return handlers[chf](data_source.data_source(data))
 
@@ -47,7 +45,7 @@ class TestFetcher:
         o.fetch(1, foon=True)
         assert [(1,), {"foon": True}] == l
         self.write_data()
-        assert self.fetcher._verify(self.fp, self.obj) == None
+        assert self.fetcher._verify(self.fp, self.obj) is None
         self.write_data("asdf")
         with pytest.raises(errors.FetchError) as excinfo:
             self.fetcher._verify(self.fp, self.obj)
@@ -59,8 +57,11 @@ class TestFetcher:
         with pytest.raises(errors.RequiredChksumDataMissing):
             self.fetcher._verify(self.fp, self.obj, handlers=subhandlers)
         self.fetcher._verify(self.fp, self.obj)
-        assert None == self.fetcher._verify(
-            self.fp, self.obj, handlers=subhandlers, all_chksums=False
+        assert (
+            self.fetcher._verify(
+                self.fp, self.obj, handlers=subhandlers, all_chksums=False
+            )
+            is None
         )
 
     def test_size_verification_first(self):
@@ -100,7 +101,7 @@ class TestFetcher:
 
     def test_normal(self):
         self.write_data()
-        assert self.fetcher._verify(self.fp, self.obj) == None
+        assert self.fetcher._verify(self.fp, self.obj) is None
         self.write_data(data[:-1])
         with pytest.raises(errors.FetchError) as excinfo:
             self.fetcher._verify(self.fp, self.obj)
@@ -123,5 +124,5 @@ class TestFetcher:
             return chksums[chf]
 
         alt_handlers = {chf: partial(f, chf) for chf in chksums}
-        assert None == self.fetcher._verify(self.fp, self.obj, 
handlers=alt_handlers)
+        assert self.fetcher._verify(self.fp, self.obj, handlers=alt_handlers) 
is None
         assert sorted(l) == sorted(alt_handlers)

diff --git a/tests/scripts/test_pmaint.py b/tests/scripts/test_pmaint.py
index 2578779b..09534654 100644
--- a/tests/scripts/test_pmaint.py
+++ b/tests/scripts/test_pmaint.py
@@ -6,7 +6,6 @@ from snakeoil.mappings import AttrAccessible
 
 from pkgcore.config import basics
 from pkgcore.config.hint import ConfigHint
-from pkgcore.ebuild.cpv import CPV
 from pkgcore.operations.repo import install, operations, replace, uninstall
 from pkgcore.repository import syncable, util
 from pkgcore.scripts import pmaint

diff --git a/tests/sync/test_base.py b/tests/sync/test_base.py
index 443720fd..489d8731 100644
--- a/tests/sync/test_base.py
+++ b/tests/sync/test_base.py
@@ -35,18 +35,18 @@ class TestSyncer:
         assert o.uri == "foon@site"
 
         with pytest.raises(base.MissingLocalUser):
-            base.Syncer(self.repo_path, f"foo_nonexistent_user::foon@site")
+            base.Syncer(self.repo_path, "foo_nonexistent_user::foon@site")
 
     @mock.patch("snakeoil.process.spawn.spawn")
     def test_usersync_disabled(self, spawn):
-        o = base.Syncer(self.repo_path, f"http://foo/bar.git";, usersync=False)
+        o = base.Syncer(self.repo_path, "http://foo/bar.git";, usersync=False)
         o.uid == os_data.uid
         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, f"http://foo/bar.git";, usersync=True)
+        o = base.Syncer(self.repo_path, "http://foo/bar.git";, usersync=True)
         o.uid == os_data.portage_uid
         o.gid == os_data.portage_gid
 
@@ -55,7 +55,7 @@ class TestSyncer:
         # and repo dir perms if it does exist
         with mock.patch("os.stat") as stat:
             stat.return_value = mock.Mock(st_uid=1234, st_gid=5678)
-            o = base.Syncer(self.repo_path, f"http://foo/bar.git";, 
usersync=True)
+            o = base.Syncer(self.repo_path, "http://foo/bar.git";, 
usersync=True)
             stat.assert_called()
             assert o.uid == 1234
             assert o.gid == 5678
@@ -144,13 +144,13 @@ class TestGenericSyncer:
         with pytest.raises(base.UriError):
             base.GenericSyncer("/", "seriouslynotaprotocol://blah/")
 
-        syncer = base.GenericSyncer("/", f"tar+https://blah.tar.gz";)
+        syncer = base.GenericSyncer("/", "tar+https://blah.tar.gz";)
         assert tar.tar_syncer is syncer.__class__
 
 
 class TestDisabledSyncer:
     def test_init(self):
-        syncer = base.DisabledSyncer("/foo/bar", f"https://blah.git";)
+        syncer = base.DisabledSyncer("/foo/bar", "https://blah.git";)
         assert syncer.disabled
         # syncing should also be disabled
         assert not syncer.uri

diff --git a/tests/sync/test_cvs.py b/tests/sync/test_cvs.py
index 8bbafbbd..e626a293 100644
--- a/tests/sync/test_cvs.py
+++ b/tests/sync/test_cvs.py
@@ -33,13 +33,13 @@ class TestCVSSyncer:
             o = cvs.cvs_syncer(str(self.repo_path), "cvs://dar:module")
             assert o.uri == ":anoncvs:dar"
             assert o.module == "module"
-            assert o.rsh == None
+            assert o.rsh is None
             assert o.env["CVSROOT"] == ":anoncvs:dar"
 
             o = cvs.cvs_syncer(str(self.repo_path), "cvs+pserver://dar:module")
             assert o.uri == ":pserver:dar"
             assert o.module == "module"
-            assert o.rsh == None
+            assert o.rsh is None
             assert o.env["CVSROOT"] == ":pserver:dar"
 
             with mock.patch(

diff --git a/tests/sync/test_rsync.py b/tests/sync/test_rsync.py
index ffa1fec9..5e5637dd 100644
--- a/tests/sync/test_rsync.py
+++ b/tests/sync/test_rsync.py
@@ -38,7 +38,7 @@ class TestRsyncSyncer:
         find_binary.side_effect = lambda x: x
         o = self._syncer_class(self.repo_path, "rsync://dar/module")
         assert o.uri == "rsync://dar/module/"
-        assert o.rsh == None
+        assert o.rsh is None
 
         o = self._syncer_class(self.repo_path, "rsync+/bin/sh://dar/module")
         assert o.uri == "rsync://dar/module/"

diff --git a/tests/util/test_parserestrict.py b/tests/util/test_parserestrict.py
index 6e20bebb..e39c116e 100644
--- a/tests/util/test_parserestrict.py
+++ b/tests/util/test_parserestrict.py
@@ -35,7 +35,7 @@ class TestExtendedRestrictionGeneration:
 
         for token in ("*", ""):
             i = parserestrict.convert_glob(token)
-            assert i == None, (
+            assert i is None, (
                 f"verifying None is returned on pointless restrictions, failed 
token: {token}"
             )
 

Reply via email to