Skip to content

Commit

Permalink
🧑‍💻 Update and apply Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Aug 16, 2024
1 parent 4e89f71 commit 2bb35d3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions tests/descriptors/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ def test_from_inner_hint_incorrect(hint: Any) -> None:
[
(Annotated[int, Field(1)], 150, b"\x08\x96\x01"),
(Annotated[uint, Field(1)], 150, b"\x08\x96\x01"),
(Annotated[List[int], Field(1)], [1, 150, 2], b"\x0A\x04\x01\x96\x01\x02"),
(Annotated[List[bytes], Field(1)], [b"B", b"C"], b"\x0A\x01B\x0A\x01C"),
(Annotated[List[int], Field(1)], [1, 150, 2], b"\x0a\x04\x01\x96\x01\x02"),
(Annotated[List[bytes], Field(1)], [b"B", b"C"], b"\x0a\x01B\x0a\x01C"),
(Annotated[Optional[bytes], Field(1)], None, b""),
(Annotated[ByteString, Field(1)], b"Testing", b"\x0A\x07Testing"),
(Annotated[ByteString, Field(1)], b"Testing", b"\x0a\x07Testing"),
(Annotated[ExampleEnum, Field(1)], ExampleEnum.BAR, b"\x08\x02"),
(
Annotated[RecursiveMessage, Field(42)],
RecursiveMessage(payload=1, inner=RecursiveMessage(payload=2)),
b"\xd2\x02\x06\x08\x01\x12\x02\x08\x02",
),
(Annotated[List[int], Field(1, packed=False)], [1, 2], b"\x08\x01\x08\x02"),
(Annotated[int, Field(1)], -2, b"\x08\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"),
(Annotated[int, Field(1)], -2, b"\x08\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01"),
# TODO: cyclic dependencies, https://github.com/eigenein/protobuf/issues/108.
],
ids=pytest_test_id,
Expand Down
2 changes: 1 addition & 1 deletion tests/descriptors/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_from_inner_hint_unsupported(inner_hint: Any) -> None:
("value", "encoded"),
[
(0.0, b"\x00\x00\x00\x00"),
(1.0, b"\x00\x00\x80\x3F"),
(1.0, b"\x00\x00\x80\x3f"),
],
)
class TestStruct:
Expand Down
6 changes: 3 additions & 3 deletions tests/io/test_varint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
UVARINT_CASES = [
(0, b"\x00"),
(3, b"\x03"),
(270, b"\x8E\x02"),
(86942, b"\x9E\xA7\x05"),
(270, b"\x8e\x02"),
(86942, b"\x9e\xa7\x05"),
]


Expand Down Expand Up @@ -61,7 +61,7 @@ def test_read_zigzag_varint(


TWOS_COMPLIMENT_TESTS = [
(-2, b"\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01"),
(-2, b"\xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01"),
(1, b"\x01"),
]

Expand Down
18 changes: 9 additions & 9 deletions tests/message/test_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Message(BaseMessage):
b: Annotated[uint, Field(2)] = uint(0)

message = Message(a=150, b=uint(42))
bytes_ = b"\x08\x96\x01\x10\x2A"
bytes_ = b"\x08\x96\x01\x10\x2a"

assert Message.loads(b"") == Message()
assert bytes(message) == bytes_
Expand Down Expand Up @@ -76,7 +76,7 @@ class Parent(BaseMessage):
c: Annotated[Child, Field(3)] = field(default_factory=Child)

message = Parent(c=Child(a=150))
bytes_ = b"\x1A\x03\x08\x96\x01"
bytes_ = b"\x1a\x03\x08\x96\x01"

assert Parent.loads(b"") == Parent()
assert bytes(message) == bytes_
Expand All @@ -103,10 +103,10 @@ class Outer(BaseMessage):
assert (
# fmt: off
Outer.loads(
b"\x0A\x00" # foo == None
b"\x0A\x02\x08\x00" # foo == [0]
b"\x0A\x03\x08\x96\x01" # foo == [150]
b"\x0A\x00", # foo == None
b"\x0a\x00" # foo == None
b"\x0a\x02\x08\x00" # foo == [0]
b"\x0a\x03\x08\x96\x01" # foo == [150]
b"\x0a\x00", # foo == None
)
== Outer(inner=Inner(foo=[0, 150]))
# fmt: on
Expand All @@ -127,8 +127,8 @@ class Outer(BaseMessage):
assert (
# fmt: off
Outer.loads(
b"\x0A\x02\x08\x01" # foo == 1
b"\x0A\x02\x08\x02", # foo == 2
b"\x0a\x02\x08\x01" # foo == 1
b"\x0a\x02\x08\x02", # foo == 2
)
== Outer(inner=Inner(foo=2))
# fmt: on
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_read_packed_repeated_as_unpacked() -> None:
class Test(BaseMessage):
foo: Annotated[List[int], Field(1, packed=False)]

assert Test.loads(b"\x0A\x04\x01\x96\x01\x02") == Test(
assert Test.loads(b"\x0a\x04\x01\x96\x01\x02") == Test(
foo=[1, 150, 2],
)

Expand Down

0 comments on commit 2bb35d3

Please sign in to comment.