Skip to content

Commit eeb60d3

Browse files
Set target version to 3.10 (#60)
1 parent 5704453 commit eeb60d3

File tree

9 files changed

+64
-61
lines changed

9 files changed

+64
-61
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ci:
33

44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.7.4
6+
rev: v0.9.3
77
hooks:
88
- id: ruff-format
99
args: ["--diff", "src", "tests"]

poetry.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ dynamic = ["dependencies"]
1616
Documentation = "https://betterproto.github.io/python-betterproto2/"
1717
Repository = "https://github.com/betterproto/python-betterproto2"
1818

19-
[project.scripts]
20-
protoc-gen-python_betterproto = "betterproto2.plugin:main"
21-
2219
[project.optional-dependencies]
2320
rust-codec = ["betterproto2-rust-codec"]
2421

@@ -41,7 +38,7 @@ tox = "^4.0.0"
4138
mkdocs-material = {version = "^9.5.49", python = ">=3.10"}
4239
mkdocstrings = {version = "^0.27.0", python = ">=3.10", extras = ["python"]}
4340
# The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml
44-
ruff = { version = "~0.7.4" }
41+
ruff = { version = "~0.9.3" }
4542
ipykernel = "^6.29.5"
4643

4744
[tool.poetry.group.test.dependencies]
@@ -56,7 +53,7 @@ cachelib = "^0.10.2"
5653

5754
[tool.ruff]
5855
extend-exclude = ["tests/output_*", "src/betterproto2/lib"]
59-
target-version = "py38"
56+
target-version = "py310"
6057
line-length = 120
6158

6259
[tool.ruff.lint]

src/betterproto2/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def dump_varint(value: int, stream: "SupportsWrite[bytes]") -> None:
259259
"""Encodes a single varint and dumps it into the provided stream."""
260260
if value < -(1 << 63):
261261
raise ValueError(
262-
"Negative value is not representable as a 64-bit integer" " - unable to encode a varint within 10 bytes."
262+
"Negative value is not representable as a 64-bit integer - unable to encode a varint within 10 bytes."
263263
)
264264
elif value < 0:
265265
value += 1 << 64
@@ -1335,7 +1335,7 @@ def _validate_field_groups(cls, values):
13351335

13361336
if len(set_fields) > 1:
13371337
set_fields_str = ", ".join(set_fields)
1338-
raise ValueError(f"Group {group} has more than one value;" f" fields {set_fields_str} are not None")
1338+
raise ValueError(f"Group {group} has more than one value; fields {set_fields_str} are not None")
13391339

13401340
return values
13411341

src/betterproto2/internal_lib/google/protobuf/__init__.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async def generate_test_case_output(test_case_input_path: Path, test_case_name:
145145
"Usage: python generate.py [-h] [-v] [DIRECTORIES or NAMES]",
146146
"Generate python classes for standard tests.",
147147
"",
148-
"DIRECTORIES One or more relative or absolute directories of test-cases to generate" "classes for.",
148+
"DIRECTORIES One or more relative or absolute directories of test-cases to generateclasses for.",
149149
" python generate.py inputs/bool inputs/double inputs/enum",
150150
"",
151151
"NAMES One or more test-case names to generate classes for.",

tests/grpc/test_grpclib_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ async def _test_client(client: ThingServiceClient, name="clean room", **kwargs):
2626

2727
def _assert_request_meta_received(deadline, metadata):
2828
def server_side_test(stream):
29-
assert stream.deadline._timestamp == pytest.approx(
30-
deadline._timestamp, 1
31-
), "The provided deadline should be received serverside"
32-
assert (
33-
stream.metadata["authorization"] == metadata["authorization"]
34-
), "The provided authorization metadata should be received serverside"
29+
assert stream.deadline._timestamp == pytest.approx(deadline._timestamp, 1), (
30+
"The provided deadline should be received serverside"
31+
)
32+
assert stream.metadata["authorization"] == metadata["authorization"], (
33+
"The provided authorization metadata should be received serverside"
34+
)
3535

3636
return server_side_test
3737

tests/test_streams.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ def test_dump_varint_file(tmp_path):
7676
betterproto2.dump_varint(123456789, stream) # Multi-byte varint
7777

7878
# Check that file contents are as expected
79-
with open(tmp_path / "dump_varint_file.out", "rb") as test_stream, open(
80-
streams_path / "message_dump_file_single.expected", "rb"
81-
) as exp_stream:
79+
with (
80+
open(tmp_path / "dump_varint_file.out", "rb") as test_stream,
81+
open(streams_path / "message_dump_file_single.expected", "rb") as exp_stream,
82+
):
8283
assert betterproto2.load_varint(test_stream) == betterproto2.load_varint(exp_stream)
8384
exp_stream.read(2)
8485
assert betterproto2.load_varint(test_stream) == betterproto2.load_varint(exp_stream)
@@ -100,9 +101,10 @@ def test_message_dump_file_single(tmp_path):
100101
oneof_example.dump(stream)
101102

102103
# Check that the outputted file is exactly as expected
103-
with open(tmp_path / "message_dump_file_single.out", "rb") as test_stream, open(
104-
streams_path / "message_dump_file_single.expected", "rb"
105-
) as exp_stream:
104+
with (
105+
open(tmp_path / "message_dump_file_single.out", "rb") as test_stream,
106+
open(streams_path / "message_dump_file_single.expected", "rb") as exp_stream,
107+
):
106108
assert test_stream.read() == exp_stream.read()
107109

108110

@@ -114,9 +116,10 @@ def test_message_dump_file_multiple(tmp_path):
114116
nested_example.dump(stream)
115117

116118
# Check that all three Messages were outputted to the file correctly
117-
with open(tmp_path / "message_dump_file_multiple.out", "rb") as test_stream, open(
118-
streams_path / "message_dump_file_multiple.expected", "rb"
119-
) as exp_stream:
119+
with (
120+
open(tmp_path / "message_dump_file_multiple.out", "rb") as test_stream,
121+
open(streams_path / "message_dump_file_multiple.expected", "rb") as exp_stream,
122+
):
120123
assert test_stream.read() == exp_stream.read()
121124

122125

@@ -126,9 +129,10 @@ def test_message_dump_delimited(tmp_path):
126129
oneof_example.dump(stream, True)
127130
nested_example.dump(stream, True)
128131

129-
with open(tmp_path / "message_dump_delimited.out", "rb") as test_stream, open(
130-
streams_path / "delimited_messages.in", "rb"
131-
) as exp_stream:
132+
with (
133+
open(tmp_path / "message_dump_delimited.out", "rb") as test_stream,
134+
open(streams_path / "delimited_messages.in", "rb") as exp_stream,
135+
):
132136
assert test_stream.read() == exp_stream.read()
133137

134138

@@ -202,9 +206,10 @@ def test_dump_varint_negative(tmp_path):
202206
with pytest.raises(ValueError):
203207
betterproto2.dump_varint(beyond, stream)
204208

205-
with open(streams_path / "dump_varint_negative.expected", "rb") as exp_stream, open(
206-
tmp_path / "dump_varint_negative.out", "rb"
207-
) as test_stream:
209+
with (
210+
open(streams_path / "dump_varint_negative.expected", "rb") as exp_stream,
211+
open(tmp_path / "dump_varint_negative.out", "rb") as test_stream,
212+
):
208213
assert test_stream.read() == exp_stream.read()
209214

210215

@@ -216,9 +221,10 @@ def test_dump_varint_positive(tmp_path):
216221
betterproto2.dump_varint(single_byte, stream)
217222
betterproto2.dump_varint(multi_byte, stream)
218223

219-
with open(tmp_path / "dump_varint_positive.out", "rb") as test_stream, open(
220-
streams_path / "dump_varint_positive.expected", "rb"
221-
) as exp_stream:
224+
with (
225+
open(tmp_path / "dump_varint_positive.out", "rb") as test_stream,
226+
open(streams_path / "dump_varint_positive.expected", "rb") as exp_stream,
227+
):
222228
assert test_stream.read() == exp_stream.read()
223229

224230

tests/test_version_check.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ def test_check_compiler_version():
77
x, y, z = (int(x) for x in __version__.split("."))
88

99
check_compiler_version(__version__)
10-
check_compiler_version(f"{x}.{y}.{z-1}")
11-
check_compiler_version(f"{x}.{y}.{z+1}")
10+
check_compiler_version(f"{x}.{y}.{z - 1}")
11+
check_compiler_version(f"{x}.{y}.{z + 1}")
1212

1313
with pytest.raises(ImportError):
14-
check_compiler_version(f"{x}.{y-1}.{z}")
14+
check_compiler_version(f"{x}.{y - 1}.{z}")
1515

1616
with pytest.raises(ImportError):
17-
check_compiler_version(f"{x}.{y+1}.{z}")
17+
check_compiler_version(f"{x}.{y + 1}.{z}")
1818

1919
with pytest.raises(ImportError):
20-
check_compiler_version(f"{x+1}.{y}.{z}")
20+
check_compiler_version(f"{x + 1}.{y}.{z}")
2121

2222
with pytest.raises(ImportError):
23-
check_compiler_version(f"{x-1}.{y}.{z}")
23+
check_compiler_version(f"{x - 1}.{y}.{z}")

0 commit comments

Comments
 (0)