From 5ff7c5b592ce1d76f5696a7f089680807ad557a6 Mon Sep 17 00:00:00 2001 From: David Douard <david.douard@sdfa3.org> Date: Mon, 4 Dec 2023 17:37:42 +0100 Subject: [PATCH] python: Fix black formatting after bump to 23.1.0 in pre-commit --- swh/model/from_disk.py | 1 - swh/model/hypothesis_strategies.py | 2 +- swh/model/model.py | 4 ++-- swh/model/tests/test_hashutil.py | 1 - swh/model/tests/test_hypothesis_strategies.py | 3 +-- swh/model/tests/test_model.py | 3 +-- swh/model/tests/test_swhids.py | 2 +- 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/swh/model/from_disk.py b/swh/model/from_disk.py index 798851a2..bd6308ec 100644 --- a/swh/model/from_disk.py +++ b/swh/model/from_disk.py @@ -567,7 +567,6 @@ class Directory(MerkleNode): """Builds a `model.Directory` object based on this node; ignoring its children.""" if self.__model_object is None: - DirectoryEntry = model.DirectoryEntry entries = [] diff --git a/swh/model/hypothesis_strategies.py b/swh/model/hypothesis_strategies.py index 45671861..8beca342 100644 --- a/swh/model/hypothesis_strategies.py +++ b/swh/model/hypothesis_strategies.py @@ -479,7 +479,7 @@ def snapshots_d(draw, *, min_size=0, max_size=100, only_objects=False): } ) except ValueError as e: - for (source, target) in e.args[1]: + for source, target in e.args[1]: branches[source] = draw(branch_targets_d(only_objects=True)) else: break diff --git a/swh/model/model.py b/swh/model/model.py index 0170bcaf..c1a6481f 100644 --- a/swh/model/model.py +++ b/swh/model/model.py @@ -229,7 +229,7 @@ def _immutable_dict_validator( key_validator = optimized_validator(expected_key_type) value_validator = optimized_validator(expected_value_type) - for (item_key, item_value) in value.items(): + for item_key, item_value in value.items(): key_validator( instance, attribute, @@ -282,7 +282,7 @@ def optimized_validator(type_): ): if origin_value is None: origin_value = value - for (validator, type_) in all_validators: + for validator, type_ in all_validators: try: validator( instance, diff --git a/swh/model/tests/test_hashutil.py b/swh/model/tests/test_hashutil.py index b279f2fa..3153ef04 100644 --- a/swh/model/tests/test_hashutil.py +++ b/swh/model/tests/test_hashutil.py @@ -36,7 +36,6 @@ def blake2_hash_cache_reset(): @pytest.fixture def hash_test_data(): class HashTestData: - data = b"1984\n" hex_checksums = { "sha1": "62be35bf00ff0c624f4a621e2ea5595a049e0731", diff --git a/swh/model/tests/test_hypothesis_strategies.py b/swh/model/tests/test_hypothesis_strategies.py index 1531ff50..e43f3127 100644 --- a/swh/model/tests/test_hypothesis_strategies.py +++ b/swh/model/tests/test_hypothesis_strategies.py @@ -63,7 +63,7 @@ def assert_nested_dict(obj): """Tests the object is a nested dict and contains no more class from swh.model.model.""" if isinstance(obj, dict): - for (key, value) in obj.items(): + for key, value in obj.items(): assert isinstance(key, (str, bytes)), key assert_nested_dict(value) elif isinstance(obj, tuple): @@ -164,7 +164,6 @@ _max_snp_size = 100 @given(snapshots(min_size=_min_snp_size, max_size=_max_snp_size)) @settings(max_examples=1) def test_snapshots_strategy(snapshot): - branches = snapshot.branches assert len(branches) >= _min_snp_size diff --git a/swh/model/tests/test_model.py b/swh/model/tests/test_model.py index 248410f9..e6182ee3 100644 --- a/swh/model/tests/test_model.py +++ b/swh/model/tests/test_model.py @@ -769,7 +769,7 @@ def test_person_comparison(): def test_content_get_hash(): hashes = dict(sha1=b"foo", sha1_git=b"bar", sha256=b"baz", blake2s256=b"qux") c = Content(length=42, status="visible", **hashes) - for (hash_name, hash_) in hashes.items(): + for hash_name, hash_ in hashes.items(): assert c.get_hash(hash_name) == hash_ @@ -1225,7 +1225,6 @@ def test_revision_check(revision): @given(strategies.revisions(raw_manifest=none())) def test_revision_raw_manifest(revision): - raw_manifest = b"foo" id_ = hashlib.new("sha1", raw_manifest).digest() diff --git a/swh/model/tests/test_swhids.py b/swh/model/tests/test_swhids.py index 5c3cab22..12a46a01 100644 --- a/swh/model/tests/test_swhids.py +++ b/swh/model/tests/test_swhids.py @@ -230,7 +230,7 @@ VALID_SWHIDS = [ def test_parse_unparse_swhids(string, core, qualified, extended): """Tests parsing and serializing valid SWHIDs with the various SWHID classes.""" classes = [CoreSWHID, QualifiedSWHID, ExtendedSWHID] - for (cls, parsed_swhid) in zip(classes, [core, qualified, extended]): + for cls, parsed_swhid in zip(classes, [core, qualified, extended]): if parsed_swhid is None: # This class should not accept this SWHID with pytest.raises(ValidationError) as excinfo: -- GitLab