Skip to content

Commit c68e231

Browse files
John-Linclaude
andcommitted
chore: replace mypy with ty for type checking
- Swap mypy for ty>=0.0.18 in dev dependencies (uv resolved 0.0.29) - Replace [tool.mypy] config with [tool.ty.environment] in pyproject.toml - Update pre-commit to use local hook running `uv run ty check` (no official ty hook yet) - Update Makefile, test.yml, and docker.yml to use ty - Replace .mypy_cache with .ty_cache in .dockerignore - Fix type errors surfaced by ty: assert message.text in _build_content, add missing `assert config is not None` guards in test_auth.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 58d5f06 commit c68e231

9 files changed

Lines changed: 44 additions & 86 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.git
2-
.mypy_cache
2+
.ty_cache
33
.pytest_cache
44
.venv
55
.ruff_cache

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Lint
2323
run: uv run ruff check .
2424
- name: Type check
25-
run: uv run mypy --install-types --non-interactive .
25+
run: uv run ty check
2626
- name: Test
2727
run: uv run pytest -v --cov=bot tests/
2828

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
- name: Lint
2121
run: uv run ruff check .
2222
- name: Type check
23-
run: uv run mypy --install-types --non-interactive .
23+
run: uv run ty check
2424
- name: Test
2525
run: uv run pytest -v --cov=bot tests/

.pre-commit-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ repos:
1111
- id: ruff
1212
args: [--fix]
1313
- id: ruff-format
14-
- repo: https://github.com/pre-commit/mirrors-mypy
15-
rev: v1.14.1
14+
- repo: local
1615
hooks:
17-
- id: mypy
18-
args: [--install-types, --non-interactive]
16+
- id: ty
17+
name: ty
18+
entry: uv run ty check
19+
language: system
20+
types: [python]
21+
pass_filenames: false
1922
- repo: https://github.com/astral-sh/uv-pre-commit
2023
rev: 0.5.15
2124
hooks:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fix:
88
uv run ruff check --fix .
99

1010
type:
11-
uv run mypy --install-types --non-interactive .
11+
uv run ty check
1212

1313
test:
1414
uv run pytest -v -s --cov=bot tests

bot/telegram.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ async def _send_typing_loop(self, update: Update) -> None:
168168
pass
169169

170170
def _build_content(self, message: Message) -> str:
171+
assert message.text is not None
171172
reply = message.reply_to_message
172173
if reply is None or not reply.text:
173174
return message.text

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ build-backend = "hatchling.build"
2121

2222
[dependency-groups]
2323
dev = [
24-
"mypy>=1.13.0",
24+
"ty>=0.0.18",
2525
"pytest>=8.3.3",
2626
"pytest-cov>=6.0.0",
2727
"ruff>=0.7.3",
@@ -51,8 +51,8 @@ select = [
5151
[tool.ruff.lint.isort]
5252
force-single-line = true
5353

54-
[tool.mypy]
55-
ignore_missing_imports = true
54+
[tool.ty.environment]
55+
python = ".venv"
5656

5757
[tool.pytest.ini_options]
5858
testpaths = ["tests"]

tests/test_auth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ def test_add_group_default_config(self):
142142
def test_add_group_no_mention(self):
143143
add_group(-1001234, require_mention=False)
144144
config = get_group_config(-1001234)
145+
assert config is not None
145146
assert config["requireMention"] is False
146147

147148
def test_add_group_with_allowed_members(self):
148149
add_group(-1001234, allowed_members=[111, 222])
149150
config = get_group_config(-1001234)
151+
assert config is not None
150152
assert config["allowFrom"] == ["111", "222"]
151153

152154
def test_get_group_config_unknown_group(self):
@@ -176,6 +178,7 @@ def test_add_group_updates_existing(self):
176178
add_group(-1001234)
177179
add_group(-1001234, require_mention=False, allowed_members=[111])
178180
config = get_group_config(-1001234)
181+
assert config is not None
179182
assert config["requireMention"] is False
180183
assert config["allowFrom"] == ["111"]
181184

uv.lock

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

0 commit comments

Comments
 (0)