From 21b0291a014d17bc4681ae66b0d900c96279fc53 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Fri, 26 Jan 2024 11:03:13 +0200 Subject: [PATCH] reformat with black 24 Signed-off-by: Arthur Zamarin --- src/snakeoil/constraints.py | 6 +++--- src/snakeoil/containers.py | 3 --- src/snakeoil/data_source.py | 3 --- src/snakeoil/demandload.py | 1 - src/snakeoil/fileutils.py | 1 - src/snakeoil/obj.py | 1 - src/snakeoil/osutils/native_readdir.py | 1 - src/snakeoil/stringio.py | 6 ++---- src/snakeoil/struct_compat.py | 1 - src/snakeoil/tar.py | 1 - tests/cli/test_arghparse.py | 7 ++++--- tests/test_osutils.py | 7 ++++--- tests/test_version.py | 21 ++++++++++++--------- 13 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/snakeoil/constraints.py b/src/snakeoil/constraints.py index c239727c..5fe46ec1 100644 --- a/src/snakeoil/constraints.py +++ b/src/snakeoil/constraints.py @@ -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. diff --git a/src/snakeoil/containers.py b/src/snakeoil/containers.py index ebfc1b39..ee14baf6 100644 --- a/src/snakeoil/containers.py +++ b/src/snakeoil/containers.py @@ -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. @@ -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. @@ -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. diff --git a/src/snakeoil/data_source.py b/src/snakeoil/data_source.py index 3b0ccb16..bb265d9f 100644 --- a/src/snakeoil/data_source.py +++ b/src/snakeoil/data_source.py @@ -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. @@ -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. @@ -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 diff --git a/src/snakeoil/demandload.py b/src/snakeoil/demandload.py index bfa6dce7..1fc6b63f 100644 --- a/src/snakeoil/demandload.py +++ b/src/snakeoil/demandload.py @@ -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. diff --git a/src/snakeoil/fileutils.py b/src/snakeoil/fileutils.py index 02355a87..fdd0f23e 100644 --- a/src/snakeoil/fileutils.py +++ b/src/snakeoil/fileutils.py @@ -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 diff --git a/src/snakeoil/obj.py b/src/snakeoil/obj.py index a8598bfb..6239b207 100644 --- a/src/snakeoil/obj.py +++ b/src/snakeoil/obj.py @@ -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 diff --git a/src/snakeoil/osutils/native_readdir.py b/src/snakeoil/osutils/native_readdir.py index 6600a719..d13e1ae1 100644 --- a/src/snakeoil/osutils/native_readdir.py +++ b/src/snakeoil/osutils/native_readdir.py @@ -1,6 +1,5 @@ """Wrapper for readdir which grabs file type from d_type.""" - import errno import os from stat import ( diff --git a/src/snakeoil/stringio.py b/src/snakeoil/stringio.py index 1a392eb4..339ec970 100644 --- a/src/snakeoil/stringio.py +++ b/src/snakeoil/stringio.py @@ -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): ... diff --git a/src/snakeoil/struct_compat.py b/src/snakeoil/struct_compat.py index 4ad5615e..66c1290c 100644 --- a/src/snakeoil/struct_compat.py +++ b/src/snakeoil/struct_compat.py @@ -17,7 +17,6 @@ # pylint: disable=function-redefined class Struct(base_struct): - """ Struct extension class adding `read` and `write` methods for handling files """ diff --git a/src/snakeoil/tar.py b/src/snakeoil/tar.py index 6f74ef28..9cae35b2 100644 --- a/src/snakeoil/tar.py +++ b/src/snakeoil/tar.py @@ -27,7 +27,6 @@ class TarInfo(tarfile.TarInfo): - """ Customized TarInfo implementation. diff --git a/tests/cli/test_arghparse.py b/tests/cli/test_arghparse.py index d0db449e..c55e786f 100644 --- a/tests/cli/test_arghparse.py +++ b/tests/cli/test_arghparse.py @@ -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(["-"]) diff --git a/tests/test_osutils.py b/tests/test_osutils.py index 82959fe4..5b5e7427 100644 --- a/tests/test_osutils.py +++ b/tests/test_osutils.py @@ -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 diff --git a/tests/test_version.py b/tests/test_version.py index 09927542..23118b36 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -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", @@ -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__) @@ -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",