Skip to content

Commit 2ac2bbb

Browse files
authored
chore: run pyright across src and tests in typecheck (#2623)
1 parent 9a1aa7d commit 2ac2bbb

21 files changed

Lines changed: 118 additions & 64 deletions

.agents/skills/code-change-verification/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Ensure work is only marked complete after formatting, linting, type checking, an
2020
## Manual workflow
2121

2222
- If dependencies are not installed or have changed, run `make sync` first to install dev requirements via `uv`.
23-
- Run from the repository root in this order: `make format`, `make lint`, `make mypy`, `make tests`.
23+
- Run from the repository root in this order: `make format`, `make lint`, `make typecheck`, `make tests`.
2424
- Do not skip steps; stop and fix issues immediately when a command fails.
2525
- Re-run the full stack after applying fixes so the commands execute in the required order.
2626

.agents/skills/code-change-verification/scripts/run.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Invoke-MakeStep {
3232

3333
Invoke-MakeStep -Step "format"
3434
Invoke-MakeStep -Step "lint"
35-
Invoke-MakeStep -Step "mypy"
35+
Invoke-MakeStep -Step "typecheck"
3636
Invoke-MakeStep -Step "tests"
3737

3838
Write-Host "code-change-verification: all commands passed."

.agents/skills/code-change-verification/scripts/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ make format
1616
echo "Running make lint..."
1717
make lint
1818

19-
echo "Running make mypy..."
20-
make mypy
19+
echo "Running make typecheck..."
20+
make typecheck
2121

2222
echo "Running make tests..."
2323
make tests

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: make sync
5959
- name: Run typecheck
6060
if: steps.changes.outputs.run == 'true'
61-
run: make mypy
61+
run: make typecheck
6262
- name: Skip typecheck
6363
if: steps.changes.outputs.run != 'true'
6464
run: echo "Skipping typecheck for non-code changes."

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ When `$code-change-verification` applies, run it to execute the required verific
129129
```
130130
- Type checking:
131131
```bash
132-
make mypy
132+
make typecheck
133133
```
134134

135135
#### Snapshot tests
@@ -155,7 +155,7 @@ Some tests rely on inline snapshots; see `tests/README.md` for details. Re-run `
155155
#### Formatting, linting, and type checking
156156

157157
- Formatting and linting use `ruff`; run `make format` (applies fixes) and `make lint` (checks only).
158-
- Type hints must pass `make mypy`.
158+
- Type hints must pass `make typecheck`.
159159
- Write comments as full sentences ending with a period.
160160
- Imports are managed by Ruff and should stay sorted.
161161

@@ -166,7 +166,7 @@ When `$code-change-verification` applies, run the full sequence in order (or use
166166
```bash
167167
make format
168168
make lint
169-
make mypy
169+
make typecheck
170170
make tests
171171
```
172172

@@ -202,12 +202,12 @@ make tests
202202

203203
- Use the template at `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md`; include a summary, test plan, and issue number if applicable.
204204
- Add tests for new behavior when feasible and update documentation for user-facing changes.
205-
- Run `make format`, `make lint`, `make mypy`, and `make tests` before marking work ready.
205+
- Run `make format`, `make lint`, `make typecheck`, and `make tests` before marking work ready.
206206
- Commit messages should be concise and written in the imperative mood. Small, focused commits are preferred.
207207

208208
### Review Process & What Reviewers Look For
209209

210-
- ✅ Checks pass (`make format`, `make lint`, `make mypy`, `make tests`).
210+
- ✅ Checks pass (`make format`, `make lint`, `make typecheck`, `make tests`).
211211
- ✅ Tests cover new behavior and edge cases.
212212
- ✅ Code is readable, maintainable, and consistent with existing style.
213213
- ✅ Public APIs and user-facing behavior changes are documented.

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ lint:
1919
mypy:
2020
uv run mypy . --exclude site
2121

22+
.PHONY: pyright
23+
pyright:
24+
uv run pyright --project pyrightconfig.json
25+
26+
.PHONY: typecheck
27+
typecheck:
28+
@set -eu; \
29+
mypy_pid=''; \
30+
pyright_pid=''; \
31+
trap 'test -n "$$mypy_pid" && kill $$mypy_pid 2>/dev/null || true; test -n "$$pyright_pid" && kill $$pyright_pid 2>/dev/null || true' EXIT INT TERM; \
32+
echo "Running make mypy and make pyright in parallel..."; \
33+
$(MAKE) mypy & mypy_pid=$$!; \
34+
$(MAKE) pyright & pyright_pid=$$!; \
35+
wait $$mypy_pid; \
36+
wait $$pyright_pid; \
37+
trap - EXIT
38+
2239
.PHONY: tests
2340
tests: tests-parallel tests-serial
2441

@@ -68,4 +85,4 @@ deploy-docs:
6885
uv run mkdocs gh-deploy --force --verbose
6986

7087
.PHONY: check
71-
check: format-check lint mypy tests
88+
check: format-check lint typecheck tests

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ dev = [
7474
"dapr>=1.14.0",
7575
"grpcio>=1.60.0",
7676
"testcontainers==4.12.0", # pinned to 4.12.0 because 4.13.0 has a warning bug in wait_for_logs, see https://github.com/testcontainers/testcontainers-python/issues/874
77+
"pyright==1.1.408",
7778
]
7879

7980
[tool.uv.workspace]

pyrightconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"include": ["src", "tests"],
3+
"extraPaths": ["."],
4+
"pythonVersion": "3.10",
5+
"typeCheckingMode": "basic",
6+
"reportAttributeAccessIssue": "none",
7+
"reportArgumentType": "none",
8+
"reportGeneralTypeIssues": "none",
9+
"reportIndexIssue": "none",
10+
"reportMissingImports": "none",
11+
"reportPrivateImportUsage": "none",
12+
"reportSelfClsParameterName": "none",
13+
"reportTypedDictNotRequiredAccess": "none",
14+
"reportUnsupportedDunderAll": "none"
15+
}

src/agents/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ def _find_mirrored_approval_record(
745745

746746
if run_result is None:
747747
if on_stream is not None:
748+
stream_handler = on_stream
748749
run_result_streaming = Runner.run_streamed(
749750
starting_agent=cast(Agent[Any], self),
750751
input=resume_state or resolved_input,
@@ -765,7 +766,7 @@ def _find_mirrored_approval_record(
765766
async def _run_handler(payload: AgentToolStreamEvent) -> None:
766767
"""Execute the user callback while capturing exceptions."""
767768
try:
768-
maybe_result = on_stream(payload)
769+
maybe_result = stream_handler(payload)
769770
if inspect.isawaitable(maybe_result):
770771
await maybe_result
771772
except Exception:

src/agents/extensions/memory/advanced_sqlite_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def _add_structure_sync():
438438
self._logger.error(f"Failed to cleanup orphaned messages: {cleanup_error}")
439439
# Don't re-raise - structure metadata is supplementary
440440

441-
async def _cleanup_orphaned_messages(self) -> None:
441+
async def _cleanup_orphaned_messages(self) -> int:
442442
"""Remove messages that exist in agent_messages but not in message_structure.
443443
444444
This can happen if _add_structure_metadata fails after super().add_items() succeeds.

0 commit comments

Comments
 (0)