Skip to main content

scripts: switch from mypy to ty for type checking

ID
9ae8db3
date
2026-06-01 22:40:25+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
4be521a
message
scripts: switch from mypy to ty for type checking
changed files
5 files, 12 additions, 21 deletions

Changed files

dev_requirements.in (89) → dev_requirements.in (107)

diff --git a/dev_requirements.in b/dev_requirements.in
index 65e242a..2f7b69d 100644
--- a/dev_requirements.in
+++ b/dev_requirements.in
@@ -1,7 +1,7 @@
--e file:.[fetch,media,static_site_tests,text,urls]
+-e file:.[browser_fixtures,fetch,media,static_site_tests,urls]
 
 coverage
-mypy
 pytest
 pytest-vcr
 ruff
+ty>=0.0.42

dev_requirements.txt (1135) → dev_requirements.txt (995)

diff --git a/dev_requirements.txt b/dev_requirements.txt
index 2bffb1f..2ffc519 100644
--- a/dev_requirements.txt
+++ b/dev_requirements.txt
@@ -1,28 +1,20 @@
 # This file was autogenerated by uv via the following command:
-#    uv pip compile dev_requirements.in --output-file=dev_requirements.txt --exclude-newer=P7D --exclude-newer-package alexwlchan-chives=false
+#    uv pip compile dev_requirements.in --output-file=dev_requirements.txt --exclude-newer-package alexwlchan-chives=false
 -e file:.
     # via -r dev_requirements.in
 certifi==2026.4.22
     # via alexwlchan-chives
 coverage==7.13.5
     # via -r dev_requirements.in
-greenlet==3.5.0
+greenlet==3.5.1
     # via playwright
 iniconfig==2.3.0
     # via pytest
-librt==0.9.0
-    # via mypy
-mypy==1.20.2
-    # via -r dev_requirements.in
-mypy-extensions==1.1.0
-    # via mypy
 packaging==26.2
     # via pytest
-pathspec==1.1.1
-    # via mypy
 pillow==12.2.0
     # via alexwlchan-chives
-playwright==1.59.0
+playwright==1.60.0
     # via alexwlchan-chives
 pluggy==1.6.0
     # via pytest
@@ -41,10 +33,10 @@ pyyaml==6.0.3
     # via vcrpy
 ruff==0.15.12
     # via -r dev_requirements.in
+ty==0.0.42
+    # via -r dev_requirements.in
 typing-extensions==4.15.0
-    # via
-    #   mypy
-    #   pyee
+    # via pyee
 vcrpy==8.1.1
     # via pytest-vcr
 wrapt==2.1.2

pyproject.toml (1512) → pyproject.toml (1511)

diff --git a/pyproject.toml b/pyproject.toml
index 8f2a956..c29f4f7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,9 +53,8 @@ fail_under = 100
 [tool.pytest.ini_options]
 filterwarnings = ["error"]
 
-[tool.mypy]
-mypy_path = "src"
-strict = true
+[tool.ty.terminal]
+error-on-warning = true
 
 [tool.ruff.lint]
 select = ["D", "E", "F"]

scripts/run_chives_tests.sh (662) → scripts/run_chives_tests.sh (666)

diff --git a/scripts/run_chives_tests.sh b/scripts/run_chives_tests.sh
index b4cfc0b..3bf66df 100755
--- a/scripts/run_chives_tests.sh
+++ b/scripts/run_chives_tests.sh
@@ -29,6 +29,6 @@ then
 fi
 
 run_command 'ruff check'
-run_command 'mypy src tests'
+run_command 'ty check src tests'
 run_command "python3 -m coverage run -m pytest -q tests"
 report_coverage

src/chives/media.py (10573) → src/chives/media.py (10579)

diff --git a/src/chives/media.py b/src/chives/media.py
index 5243cd2..b5cf39d 100644
--- a/src/chives/media.py
+++ b/src/chives/media.py
@@ -21,7 +21,7 @@ import subprocess
 from typing import Literal, NotRequired, TypedDict, TYPE_CHECKING
 
 if TYPE_CHECKING:
-    import PIL
+    import PIL.Image
 
 
 __all__ = [