Skip to content

Commit

Permalink
reformat with black 24
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Zamarin <[email protected]>
  • Loading branch information
arthurzam committed Jan 26, 2024
1 parent 4490872 commit 21b0291
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/snakeoil/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class Problem:
def __init__(self):
self.variables: dict[str, _Domain] = {}
self.constraints: list[tuple[Constraint, frozenset[str]]] = []
self.vconstraints: dict[
str, list[tuple[Constraint, frozenset[str]]]
] = defaultdict(list)
self.vconstraints: dict[str, list[tuple[Constraint, frozenset[str]]]] = (
defaultdict(list)
)

def add_variable(self, domain: Iterable[Any], *variables: str):
"""Add variables to the problem, which use the specified domain.
Expand Down
3 changes: 0 additions & 3 deletions src/snakeoil/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class InvertedContains(set):

"""Set that inverts all contains lookup results.
Essentially, it's a set class usable for blacklist containment testing.
Expand Down Expand Up @@ -97,7 +96,6 @@ def __rsub__(self, other):


class LimitedChangeSet(SetMixin):

"""
Set used to limit the number of times a key can be removed/added.
Expand Down Expand Up @@ -263,7 +261,6 @@ def add(self, key):


class RefCountingSet(dict):

"""
Set implementation that implements refcounting for add/remove, removing the key only when its refcount is 0.
Expand Down
3 changes: 0 additions & 3 deletions src/snakeoil/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def transfer_to_data_source(self, write_source):


class local_source(base):

"""locally accessible data source
Literally a file on disk.
Expand Down Expand Up @@ -289,7 +288,6 @@ def _set_data(self, data):


class data_source(base):

"""
base class encapsulating a purely virtual data source lacking an on disk location.
Expand Down Expand Up @@ -389,7 +387,6 @@ def _convert_data(self, mode):


class invokable_data_source(data_source):

"""
data source that takes a callable instead of the actual data item
Expand Down
1 change: 0 additions & 1 deletion src/snakeoil/demandload.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def _noisy_protection_enabled():


class Placeholder:

"""Object that knows how to replace itself when first accessed.
See the module docstring for common problems with its use.
Expand Down
1 change: 0 additions & 1 deletion src/snakeoil/fileutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def mmap_or_open_for_read(path: str):


class AtomicWriteFile_mixin:

"""File class that stores the changes in a tempfile.
Upon invocation of the close method, this class will use
Expand Down
1 change: 0 additions & 1 deletion src/snakeoil/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
try to proxy builtin objects like tuples, lists, dicts, sets, etc.
"""


__all__ = ("DelayedInstantiation", "DelayedInstantiation_kls", "make_kls", "popattr")

from . import klass
Expand Down
1 change: 0 additions & 1 deletion src/snakeoil/osutils/native_readdir.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Wrapper for readdir which grabs file type from d_type."""


import errno
import os
from stat import (
Expand Down
6 changes: 2 additions & 4 deletions src/snakeoil/stringio.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def __new__(cls, name, bases, dct):
return x


class text_readonly(io.StringIO, metaclass=_make_ro_cls):
...
class text_readonly(io.StringIO, metaclass=_make_ro_cls): ...


class bytes_readonly(io.BytesIO, metaclass=_make_ro_cls):
...
class bytes_readonly(io.BytesIO, metaclass=_make_ro_cls): ...
1 change: 0 additions & 1 deletion src/snakeoil/struct_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

# pylint: disable=function-redefined
class Struct(base_struct):

"""
Struct extension class adding `read` and `write` methods for handling files
"""
Expand Down
1 change: 0 additions & 1 deletion src/snakeoil/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@


class TarInfo(tarfile.TarInfo):

"""
Customized TarInfo implementation.
Expand Down
7 changes: 4 additions & 3 deletions tests/cli/test_arghparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ def test_stdin(self):
(["foo", "bar", "baz"], ["foo", "bar", "baz"]),
(["\nfoo\n", " bar ", "\nbaz"], ["\nfoo", " bar", "\nbaz"]),
):
with mock.patch("sys.stdin") as stdin, mock.patch(
"builtins.open", mock.mock_open()
) as mock_file:
with (
mock.patch("sys.stdin") as stdin,
mock.patch("builtins.open", mock.mock_open()) as mock_file,
):
stdin.readlines.return_value = readlines
stdin.isatty.return_value = False
namespace = self.parser.parse_args(["-"])
Expand Down
7 changes: 4 additions & 3 deletions tests/test_osutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ def test_chmod_or_chown_failing(self, tmp_path):
path.mkdir()
path.chmod(0o750)

with mock.patch("snakeoil.osutils.os.chmod") as chmod, mock.patch(
"snakeoil.osutils.os.chown"
) as chown:
with (
mock.patch("snakeoil.osutils.os.chmod") as chmod,
mock.patch("snakeoil.osutils.os.chown") as chown,
):
chmod.side_effect = OSError(5, "Input/output error")

# chmod failure when file exists and trying to reset perms to match
Expand Down
21 changes: 12 additions & 9 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ def test_get_version_api(self):
assert v.startswith("snakeoil 9.9.9")

def test_get_version_git_dev(self):
with mock.patch("snakeoil.version.import_module") as import_module, mock.patch(
"snakeoil.version.get_git_version"
) as get_git_version:
with (
mock.patch("snakeoil.version.import_module") as import_module,
mock.patch("snakeoil.version.get_git_version") as get_git_version,
):
import_module.side_effect = ImportError
verinfo = {
"rev": "1ff76b021d208f7df38ac524537b6419404f1c64",
Expand Down Expand Up @@ -57,9 +58,10 @@ class Verinfo:
assert result == f"snakeoil {verinfo['tag']} -- released {verinfo['date']}"

def test_get_version_no_git_version(self):
with mock.patch("snakeoil.version.import_module") as import_module, mock.patch(
"snakeoil.version.get_git_version"
) as get_git_version:
with (
mock.patch("snakeoil.version.import_module") as import_module,
mock.patch("snakeoil.version.get_git_version") as get_git_version,
):
import_module.side_effect = ImportError
get_git_version.return_value = None
result = version.get_version("snakeoil", "nonexistent", __version__)
Expand Down Expand Up @@ -113,9 +115,10 @@ def test_get_git_version_good_dev(self):
assert result == expected

def test_get_git_version_good_tag(self):
with mock.patch("snakeoil.version._run_git") as run_git, mock.patch(
"snakeoil.version._get_git_tag"
) as get_git_tag:
with (
mock.patch("snakeoil.version._run_git") as run_git,
mock.patch("snakeoil.version._get_git_tag") as get_git_tag,
):
# tagged, release version
run_git.return_value = (
b"1ff76b021d208f7df38ac524537b6419404f1c64\nMon Sep 25 13:50:24 2017 -0400",
Expand Down

0 comments on commit 21b0291

Please sign in to comment.