Skip to content

Commit e858ce3

Browse files
committed
Replace pre-commit and pyright with prek and ty
1 parent 6431ef1 commit e858ce3

11 files changed

Lines changed: 126 additions & 184 deletions

.github/workflows/build.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on:
55
workflow_call:
66
workflow_dispatch:
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
build:
13+
name: Build distributions
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Checkout repository

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919

2020
test:
2121
name: Test
22+
needs: build
2223
uses: ./.github/workflows/test.yaml
2324
secrets: inherit
2425

.github/workflows/lint.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,38 @@ on:
66
workflow_call:
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
concurrency: lint-${{ github.sha }}
1013

1114
jobs:
1215
lint:
16+
name: Lint and type check with Python ${{ matrix.python-version }}
1317
runs-on: ubuntu-latest
14-
env:
15-
PYTHON_VERSION: "3.10"
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version:
22+
- "3.10"
23+
- "3.11"
24+
- "3.12"
25+
- "3.13"
26+
- "3.14"
1627
steps:
1728
- name: Checkout repository
1829
uses: actions/checkout@v6
1930

20-
- name: Set up Python ${{ env.PYTHON_VERSION }}
31+
- name: Set up Python ${{ matrix.python-version }}
2132
uses: actions/setup-python@v6
2233
with:
23-
python-version: ${{ env.PYTHON_VERSION }}
34+
python-version: ${{ matrix.python-version }}
2435

2536
- name: Install uv
2637
uses: astral-sh/setup-uv@v7
2738

28-
- name: Install the project
29-
run: uv sync --all-extras --dev
39+
- name: Install project dependencies
40+
run: uv sync --all-groups --python ${{ matrix.python-version }}
3041

31-
- name: Run pre-commit hooks
32-
uses: pre-commit/action@v3.0.1
42+
- name: Run hooks
43+
uses: j178/prek-action@v1

.github/workflows/test.yaml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,51 @@ on:
66
workflow_call:
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
concurrency: test-${{ github.sha }}
1013

1114
jobs:
1215
test:
16+
name: Test with Python ${{ matrix.python-version }}
1317
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version:
22+
- "3.10"
23+
- "3.11"
24+
- "3.12"
25+
- "3.13"
26+
- "3.14"
1427
env:
15-
PYTHON_VERSION: "3.10"
1628
CONTIGUITY_PROJECT_ID: ${{ secrets.CONTIGUITY_PROJECT_ID }}
1729
CONTIGUITY_TOKEN: ${{ secrets.CONTIGUITY_TOKEN }}
1830
CONTIGUITY_DATA_KEY: ${{ secrets.CONTIGUITY_DATA_KEY }}
1931
steps:
2032
- name: Checkout repository
2133
uses: actions/checkout@v6
2234

23-
- name: Set up Python ${{ env.PYTHON_VERSION }}
35+
- name: Set up Python ${{ matrix.python-version }}
2436
uses: actions/setup-python@v6
2537
with:
26-
python-version: ${{ env.PYTHON_VERSION }}
38+
python-version: ${{ matrix.python-version }}
2739

2840
- name: Install uv
2941
uses: astral-sh/setup-uv@v7
3042

31-
- name: Install the project
32-
run: uv sync --all-extras --dev
43+
- name: Install project dependencies
44+
run: uv sync --no-install-project --all-groups --python ${{ matrix.python-version }}
45+
46+
- name: Download sdist artifact
47+
uses: actions/download-artifact@v6
48+
with:
49+
name: sdist
50+
path: ./dist
51+
52+
- name: Install package
53+
run: uv pip install dist/*.tar.gz
3354

34-
- name: Run tests
55+
- name: Run pytest
3556
run: uv run pytest tests

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ repos:
1616
- id: ruff
1717
- id: ruff-format
1818

19-
- repo: https://github.com/RobertCraigie/pyright-python
20-
rev: v1.1.407
19+
- repo: local
2120
hooks:
22-
- id: pyright
21+
- id: ty-check
22+
name: ty check
23+
description: Type check with ty.
24+
entry: uvx ty check
25+
language: system
26+
pass_filenames: false
27+
require_serial: true

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ dependencies = [
4242

4343
[dependency-groups]
4444
dev = [
45-
"pre-commit~=4.5.0",
45+
"prek>=0.2.22",
4646
"pytest~=9.0.2",
4747
"pytest-asyncio~=1.3.0",
4848
"pytest-cov~=7.0.0",
4949
"python-dotenv~=1.2.1",
50+
"ty>=0.0.2",
5051
]
5152

5253
[project.urls]
@@ -70,10 +71,5 @@ ignore = ["A", "D", "T201"]
7071
[tool.ruff.lint.per-file-ignores]
7172
"**/tests/*" = ["S101", "S311"]
7273

73-
[tool.pyright]
74-
venvPath = "."
75-
venv = ".venv"
76-
reportUnnecessaryTypeIgnoreComment = true
77-
7874
[tool.pytest.ini_options]
7975
asyncio_mode = "auto"

tests/base/test_async_base_dict_typed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ async def test_update(base: AsyncBase[DictItemType]) -> None:
131131
assert updated_item == {
132132
"key": "test_key",
133133
"field1": "updated_value",
134-
"field3": item["field3"] + 2,
135-
"field4": item["field4"] - 2,
136-
"field5": [*item["field5"], "baz"],
137-
"field6": [3, 4, *item["field6"]],
134+
"field3": item["field3"] + 2, # ty: ignore[unsupported-operator]
135+
"field4": item["field4"] - 2, # ty: ignore[unsupported-operator]
136+
"field5": [*item["field5"], "baz"], # ty: ignore[not-iterable]
137+
"field6": [3, 4, *item["field6"]], # ty: ignore[not-iterable]
138138
"field7": item["field7"],
139139
}
140140

tests/base/test_async_base_dict_untyped.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ async def test_update(base: AsyncBase) -> None:
129129
assert updated_item == {
130130
"key": "test_key",
131131
"field1": "updated_value",
132-
"field3": item["field3"] + 2,
133-
"field4": item["field4"] - 2,
134-
"field5": [*item["field5"], "baz"],
135-
"field6": [3, 4, *item["field6"]],
132+
"field3": item["field3"] + 2, # ty: ignore[unsupported-operator]
133+
"field4": item["field4"] - 2, # ty: ignore[unsupported-operator]
134+
"field5": [*item["field5"], "baz"], # ty: ignore[not-iterable]
135+
"field6": [3, 4, *item["field6"]], # ty: ignore[not-iterable]
136136
"field7": item["field7"],
137137
}
138138

tests/base/test_base_dict_typed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def test_update(base: Base[DictItemType]) -> None:
131131
assert updated_item == {
132132
"key": "test_key",
133133
"field1": "updated_value",
134-
"field3": item["field3"] + 2,
135-
"field4": item["field4"] - 2,
136-
"field5": [*item["field5"], "baz"],
137-
"field6": [3, 4, *item["field6"]],
134+
"field3": item["field3"] + 2, # ty: ignore[unsupported-operator]
135+
"field4": item["field4"] - 2, # ty: ignore[unsupported-operator]
136+
"field5": [*item["field5"], "baz"], # ty: ignore[not-iterable]
137+
"field6": [3, 4, *item["field6"]], # ty: ignore[not-iterable]
138138
"field7": item["field7"],
139139
}
140140

tests/base/test_base_dict_untyped.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ def test_update(base: Base) -> None:
129129
assert updated_item == {
130130
"key": "test_key",
131131
"field1": "updated_value",
132-
"field3": item["field3"] + 2,
133-
"field4": item["field4"] - 2,
134-
"field5": [*item["field5"], "baz"],
135-
"field6": [3, 4, *item["field6"]],
132+
"field3": item["field3"] + 2, # ty: ignore[unsupported-operator]
133+
"field4": item["field4"] - 2, # ty: ignore[unsupported-operator]
134+
"field5": [*item["field5"], "baz"], # ty: ignore[not-iterable]
135+
"field6": [3, 4, *item["field6"]], # ty: ignore[not-iterable]
136136
"field7": item["field7"],
137137
}
138138

0 commit comments

Comments
 (0)