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

Commit 9c9df60

Browse files
Simplify models, fix typing (#23)
* Remove __post_init__ functions * Remove __post_init__ from MessageCompiler * Remove outdated comment * Fix typing error * Fix typing error * Remove placeholders * Remove comment * Remove parent property from ProtoContentBase * Simplify annotations * Rename parent variable * Remove useless method * Fix bug * Fix bug * Move deprecated function * Fix typing errors * Remove useless code * Fix typing error in code validation * Fix typing error * Fix typin gerrors with unwrap * Add pyright * Poe command for pyright * Use pyright in workflow * Typecheck only source code for now * Use poetry command * Don't make EnumDefinitionCompiler inherit from MessageCompiler * Fix inheritance * Fix workflow permissions
1 parent b027f46 commit 9c9df60

File tree

7 files changed

+883
-287
lines changed

7 files changed

+883
-287
lines changed

.github/workflows/code-quality.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,45 @@ on:
88
branches:
99
- '**'
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
12-
check-formatting:
13-
name: Check code/doc formatting
15+
check:
16+
name: Check code formatting, typecheck the code
1417
runs-on: ubuntu-latest
1518
steps:
16-
- uses: actions/checkout@v3
17-
- uses: actions/setup-python@v4
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
22+
- name: Install poetry
23+
shell: bash
24+
run: |
25+
python -m pip install poetry
26+
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
27+
28+
- name: Configure poetry
29+
shell: bash
30+
run: poetry config virtualenvs.in-project true
31+
32+
- name: Set up cache
33+
uses: actions/cache@v3
34+
id: cache
35+
with:
36+
path: .venv
37+
key: venv-quality-${{ hashFiles('**/poetry.lock') }}
38+
39+
- name: Ensure cache is healthy
40+
if: steps.cache.outputs.cache-hit == 'true'
41+
shell: bash
42+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
43+
44+
- name: Install dependencies
45+
shell: bash
46+
run: poetry install
47+
1848
- uses: pre-commit/[email protected]
49+
50+
- name: Pyright
51+
shell: bash
52+
run: poetry run poe typecheck

poetry.lock

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

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ packages = [
1313

1414
[tool.poetry.dependencies]
1515
python = "^3.10"
16-
betterproto2 = "^0.1.1"
16+
betterproto2 = "^0.1.3"
1717
# The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml
1818
ruff = "~0.7.4"
1919
grpclib = "^0.4.1"
2020
jinja2 = ">=3.0.3"
2121
typing-extensions = "^4.7.1"
2222

2323
[tool.poetry.group.dev.dependencies]
24-
mypy = "^1.11.2"
2524
pre-commit = "^2.17.0"
2625
grpcio-tools = "^1.54.2"
2726
mkdocs-material = {version = "^9.5.49", python = ">=3.10"}
2827
mkdocstrings = {version = "^0.27.0", python = ">=3.10", extras = ["python"]}
2928
poethepoet = ">=0.9.0"
29+
pyright = "^1.1.391"
30+
ipykernel = "^6.29.5"
3031

3132
[tool.poetry.group.test.dependencies]
3233
pytest = "^6.2.5"
@@ -54,8 +55,6 @@ select = [
5455
"UP",
5556

5657
"I",
57-
58-
"COM812", # Trailing commas
5958
]
6059

6160

@@ -72,9 +71,9 @@ help = "Run tests"
7271
script = "tests.generate:main"
7372
help = "Generate test cases"
7473

75-
[tool.poe.tasks.types]
76-
cmd = "mypy src --ignore-missing-imports"
77-
help = "Check types with mypy"
74+
[tool.poe.tasks.typecheck]
75+
cmd = "pyright src"
76+
help = "Typecheck the code with Pyright"
7877

7978
[tool.poe.tasks.format]
8079
sequence = ["_format", "_sort-imports"]

0 commit comments

Comments
 (0)