Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 94a7999

Browse files
Update workflows (#46)
* Poetry 2, update workflows * Update Ruff
1 parent f80c9d3 commit 94a7999

File tree

9 files changed

+162
-37
lines changed

9 files changed

+162
-37
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: poetry config virtualenvs.in-project true
4242

4343
- name: Set up cache
44-
uses: actions/cache@v3
44+
uses: actions/cache@v4
4545
id: cache
4646
with:
4747
path: .venv

.github/workflows/code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
shell: bash
4646
run: poetry install
4747

48-
- uses: pre-commit/action@v2.0.3
48+
- uses: pre-commit/action@v3.0.1
4949

5050
- name: Pyright
5151
shell: bash

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v4
2525

2626
- name: Set up Python 3.10
27-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2828
with:
2929
python-version: "3.10"
3030

.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"]

docs/getting-started.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
The betterproto2 compiler is a plugin of `protoc`, you first need to [install](https://grpc.io/docs/protoc-installation/) it.
66

7+
You can also use it from `grpcio-tools`:
8+
9+
```sh
10+
pip install grpcio-tools
11+
```
12+
13+
714
## Install `betterproto2_compiler`
815

916
It is possible to install `betterproto2_compiler` using pip:
@@ -15,6 +22,7 @@ pip install betterproto2_compiler
1522
!!! warning
1623
The compiler needs Python 3.10, 3.11 or 3.12. Don't worry! The generated code will be compatible with all Python versions from Python 3.8 to Python 3.13.
1724

25+
1826
## Compile a proto file
1927

2028
Create the following `example.proto` file.
@@ -35,3 +43,9 @@ You should now be able to compile it using:
3543
mkdir lib
3644
protoc -I . --python_betterproto2_out=lib example.proto
3745
```
46+
47+
If you installed `protoc` with `grpc-tools`, the command will be:
48+
49+
```mkdir lib
50+
python -m grpc-tools.protoc -I . --python_betterproto2_out=lib example.proto
51+
```

poetry.lock

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

pyproject.toml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
[tool.poetry]
1+
[project]
22
name = "betterproto2_compiler"
33
version = "0.2.3"
44
description = "Compiler for betterproto2"
5-
authors = ["Adrien Vannson <[email protected]>", "Daniel G. Taylor <[email protected]>"]
5+
authors = [
6+
{ name = "Adrien Vannson", email = "[email protected]" },
7+
{ name = "Daniel G. Taylor", email = "[email protected]" },
8+
]
69
readme = "README.md"
7-
repository = "https://github.com/betterproto/python-betterproto2-compiler"
810
keywords = ["protobuf", "gRPC", "compiler"]
911
license = "MIT"
12+
requires-python = ">=3.10,<4.0"
13+
dynamic = ["dependencies"]
14+
15+
[project.urls]
16+
Documentation = "https://betterproto.github.io/python-betterproto2-compiler/"
17+
Repository = "https://github.com/betterproto/python-betterproto2-compiler"
18+
19+
[project.scripts]
20+
protoc-gen-python_betterproto2 = "betterproto2_compiler.plugin:main"
21+
22+
[tool.poetry]
1023
packages = [
1124
{ include = "betterproto2_compiler", from = "src" }
1225
]
@@ -15,7 +28,7 @@ packages = [
1528
python = "^3.10"
1629
betterproto2 = "^0.2.1"
1730
# The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml
18-
ruff = "~0.7.4"
31+
ruff = "~0.9.3"
1932
grpclib = "^0.4.1"
2033
jinja2 = ">=3.0.3"
2134
typing-extensions = "^4.7.1"
@@ -33,9 +46,6 @@ ipykernel = "^6.29.5"
3346
pytest = "^6.2.5"
3447
protobuf = "^4"
3548

36-
[tool.poetry.scripts]
37-
protoc-gen-python_betterproto2 = "betterproto2_compiler.plugin:main"
38-
3949
[tool.ruff]
4050
extend-exclude = ["tests/output_*", "src/betterproto2_compiler/lib"]
4151
target-version = "py310"

src/betterproto2_compiler/known_types/timestamp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def timestamp_to_json(dt: datetime.datetime) -> str:
3737
return f"{result}Z"
3838
if (nanos % 1e6) == 0:
3939
# Serialize 3 fractional digits.
40-
return f"{result}.{int(nanos // 1e6) :03d}Z"
40+
return f"{result}.{int(nanos // 1e6):03d}Z"
4141
if (nanos % 1e3) == 0:
4242
# Serialize 6 fractional digits.
43-
return f"{result}.{int(nanos // 1e3) :06d}Z"
43+
return f"{result}.{int(nanos // 1e3):06d}Z"
4444
# Serialize 9 fractional digits.
4545
return f"{result}.{nanos:09d}"

tests/generate.py

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

0 commit comments

Comments
 (0)