Skip to content

Commit 02cb2e3

Browse files
committed
feat: add ty for type-checking
1 parent 6984ee7 commit 02cb2e3

File tree

10 files changed

+40
-106
lines changed

10 files changed

+40
-106
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: uv sync --all-groups
3434

3535
- name: Run type checker
36-
run: uv run mypy src
36+
run: uv run ty check src
3737

3838
test:
3939
runs-on: ubuntu-latest

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,6 @@ venv.bak/
154154
# mkdocs documentation
155155
/site
156156

157-
# mypy
158-
.mypy_cache/
159-
.dmypy.json
160-
dmypy.json
161-
162157
# Pyre type checker
163158
.pyre/
164159

.pre-commit-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ repos:
66
args: [--fix]
77
- id: ruff-format
88

9-
- repo: https://github.com/pre-commit/mirrors-mypy
10-
rev: v1.13.0
9+
- repo: local
1110
hooks:
12-
- id: mypy
11+
- id: ty
12+
name: ty
13+
entry: uv run ty check src
14+
language: system
15+
types: [python]
16+
pass_filenames: false
1317
stages: [pre-push]
14-
additional_dependencies: [textual, claude-agent-sdk, pydantic, types-PyYAML]

.vscode/settings.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33
"editor.tabSize": 4,
44
"editor.insertSpaces": true,
55
"files.exclude": {
6-
"**/.mypy_cache": true,
76
"**/.ruff_cache": true,
87
"**/.venv": true,
98
"**/__pycache__": true,
109
"**/agent_chat_cli.egg-info": true,
1110
},
12-
"mypy.dmypyExecutable": "${workspaceFolder}/.venv/bin/dmypy",
13-
"mypy.runUsingActiveInterpreter": true,
1411
"ruff.enable": true,
1512
"ruff.lint.enable": true,
16-
"python.analysis.autoImportCompletions": true,
17-
"python.analysis.typeCheckingMode": "basic",
18-
"python.analysis.inlayHints.functionReturnTypes": false,
19-
"python.analysis.inlayHints.variableTypes": false,
13+
"python.languageServer": "None",
2014

2115
"[python]": {
2216
"editor.defaultFormatter": "charliermarsh.ruff",

CLAUDE.md

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

55
- Read `docs/architecture.md` for an architectural overview of the project. Refactors should always start here first.
6-
- The project uses `uv`, `ruff` and `mypy`
6+
- The project uses `uv`, `ruff` and `ty`
77
- Run commands should be prefixed with `uv`: `uv run ...`
88
- Use `asyncio` features, if such is needed
99
- Prefer early returns

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ test:
1919
uv run pytest
2020

2121
type-check:
22-
uv run mypy src
22+
uv run ty check src

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Additional MCP servers are configured in `agent-chat-cli.config.yaml` and prompt
3838

3939
- Install pre-commit hooks via [pre-commit](https://pre-commit.com/)
4040
- `uv run pre-commit install`
41-
- Type-checking is via [MyPy](https://github.com/python/mypy):
41+
- Type-checking is via [ty](https://github.com/astral-sh/ty):
4242
- `make type-check`
4343
- Linting and formatting is via [Ruff](https://docs.astral.sh/ruff/)
4444
- `make lint`

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ requires-python = ">=3.14"
77
dependencies = [
88
"asyncio>=4.0.0",
99
"claude-agent-sdk>=0.1.10",
10-
"mypy>=1.19.0",
1110
"pydantic>=2.12.5",
1211
"python-dotenv>=1.2.1",
1312
"pyyaml>=6.0.3",
@@ -17,14 +16,13 @@ dependencies = [
1716

1817
[dependency-groups]
1918
dev = [
20-
"mypy>=1.19.0",
2119
"pre-commit>=4.3.0",
2220
"pytest>=8.0.0",
2321
"pytest-asyncio>=0.24.0",
2422
"pytest-textual-snapshot>=1.0.0",
2523
"ruff>=0.14.7",
2624
"textual-dev>=1.8.0",
27-
"types-pyyaml>=6.0.12.20250915",
25+
"ty>=0.0.2",
2826
]
2927

3028
[project.scripts]

src/agent_chat_cli/core/agent_loop.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from claude_agent_sdk.types import (
1010
AssistantMessage,
1111
Message,
12+
StreamEvent,
1213
SystemMessage,
1314
TextBlock,
1415
ToolUseBlock,
@@ -124,8 +125,8 @@ async def _handle_message(self, message: Message) -> None:
124125
MCPServerStatus.update(message.data["mcp_servers"])
125126

126127
# Handle streaming messages
127-
if hasattr(message, "event"):
128-
event = message.event # type: ignore[attr-defined]
128+
if isinstance(message, StreamEvent):
129+
event = message.event
129130

130131
if event.get("type") == ContentType.CONTENT_BLOCK_DELTA.value:
131132
delta = event.get("delta", {})

uv.lock

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

0 commit comments

Comments
 (0)