Skip to content

Commit 136c151

Browse files
committed
ruff format
1 parent 1ad4c14 commit 136c151

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

tests/test_common.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,15 +1816,20 @@ class Test(Struct, forbid_unknown_fields=forbid_on_cls):
18161816
y: int
18171817

18181818
good = Test(1, 2)
1819-
assert proto.decode(
1820-
proto.encode(good),
1821-
type=Test,
1822-
forbid_unknown_fields=not forbid_on_cls,
1823-
) == good
1819+
assert (
1820+
proto.decode(
1821+
proto.encode(good), type=Test, forbid_unknown_fields=not forbid_on_cls
1822+
)
1823+
== good
1824+
)
18241825

18251826
bad = proto.encode({"x": 1, "y": 2, "z": 3})
18261827
with pytest.raises(ValidationError, match="Object contains unknown field `z`"):
1827-
proto.decode(bad, type=Test, forbid_unknown_fields=not forbid_on_cls,)
1828+
proto.decode(
1829+
bad,
1830+
type=Test,
1831+
forbid_unknown_fields=not forbid_on_cls,
1832+
)
18281833

18291834
@pytest.mark.parametrize("forbid_on_cls", [True, False])
18301835
def test_forbid_unknown_fields_array_like(self, proto, forbid_on_cls):
@@ -1833,11 +1838,14 @@ class Test(Struct, forbid_unknown_fields=forbid_on_cls, array_like=True):
18331838
y: int
18341839

18351840
good = Test(1, 2)
1836-
assert proto.decode(
1837-
proto.encode(good),
1838-
type=Test,
1839-
forbid_unknown_fields=not forbid_on_cls,
1840-
) == good
1841+
assert (
1842+
proto.decode(
1843+
proto.encode(good),
1844+
type=Test,
1845+
forbid_unknown_fields=not forbid_on_cls,
1846+
)
1847+
== good
1848+
)
18411849

18421850
bad = proto.encode([1, 2, 3])
18431851
with pytest.raises(
@@ -2794,7 +2802,9 @@ class Example:
27942802
assert res == msg
27952803

27962804
# Extra fields ignored
2797-
encoded = proto.encode({"x": -1, "a": 1, "y": -2, "b": 2, "z": -3, "c": 3, "": -4})
2805+
encoded = proto.encode(
2806+
{"x": -1, "a": 1, "y": -2, "b": 2, "z": -3, "c": 3, "": -4}
2807+
)
27982808
if forbid_unknown_fields:
27992809
with pytest.raises(ValidationError, match="Object contains unknown field"):
28002810
dec.decode(encoded)

tests/test_convert.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,13 @@ class Ex(Struct, rename="camel"):
17471747
@pytest.mark.parametrize("forbid_unknown_fields_on_cls", [False, True])
17481748
@pytest.mark.parametrize("forbid_unknown_fields_on_call", [False, True])
17491749
@mapcls_and_from_attributes
1750-
def test_struct_extra_fields(self, forbid_unknown_fields_on_cls,
1751-
forbid_unknown_fields_on_call, mapcls, from_attributes):
1750+
def test_struct_extra_fields(
1751+
self,
1752+
forbid_unknown_fields_on_cls,
1753+
forbid_unknown_fields_on_call,
1754+
mapcls,
1755+
from_attributes,
1756+
):
17521757
class Ex(Struct, forbid_unknown_fields=forbid_unknown_fields_on_cls):
17531758
a: int
17541759
b: int
@@ -1757,11 +1762,19 @@ class Ex(Struct, forbid_unknown_fields=forbid_unknown_fields_on_cls):
17571762
forbid_unknown = forbid_unknown_fields_on_cls or forbid_unknown_fields_on_call
17581763
if forbid_unknown and issubclass(mapcls, dict):
17591764
with pytest.raises(ValidationError, match="unknown field `x`"):
1760-
convert(msg, Ex, from_attributes=from_attributes,
1761-
forbid_unknown_fields=forbid_unknown_fields_on_call)
1765+
convert(
1766+
msg,
1767+
Ex,
1768+
from_attributes=from_attributes,
1769+
forbid_unknown_fields=forbid_unknown_fields_on_call,
1770+
)
17621771
else:
1763-
res = convert(msg, Ex, from_attributes=from_attributes,
1764-
forbid_unknown_fields=forbid_unknown_fields_on_call)
1772+
res = convert(
1773+
msg,
1774+
Ex,
1775+
from_attributes=from_attributes,
1776+
forbid_unknown_fields=forbid_unknown_fields_on_call,
1777+
)
17651778
assert res == Ex(2, 4)
17661779

17671780
@mapcls_and_from_attributes

0 commit comments

Comments
 (0)