Skip to content

Commit e8ea7f2

Browse files
committed
Refactor: Replace pyright with ty for static type checking
1 parent c3546d2 commit e8ea7f2

5 files changed

Lines changed: 70 additions & 67 deletions

File tree

.github/workflows/continuous-deployment.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
name: Check with Ruff
2222
uses: astral-sh/ruff-action@v3
2323
with:
24-
args: 'check --exit-zero --verbose'
24+
args: "check --exit-zero --verbose"
2525

2626
- id: format-ruff
2727
name: Format with Ruff
2828
uses: astral-sh/ruff-action@v3
2929
with:
30-
args: 'format --check --verbose'
30+
args: "format --check --verbose"
3131

32-
pyright:
32+
type-check:
3333
name: Verify static typing
3434
runs-on: ubuntu-latest
3535
steps:
@@ -40,18 +40,18 @@ jobs:
4040
- name: Setup uv
4141
uses: astral-sh/setup-uv@v7
4242
with:
43-
version: 'latest'
43+
version: "latest"
4444
enable-cache: true
45-
cache-dependency-glob: '**/pyproject.toml'
45+
cache-dependency-glob: "**/pyproject.toml"
4646

4747
- id: install-python-dependencies
4848
name: Install Python dependencies
4949
run: uv sync --extra dev
5050

51-
- id: pyright
52-
name: Run pyright
51+
- id: type-check
52+
name: Run ty
5353
timeout-minutes: 10
54-
run: uv run pyright
54+
run: uv run ty check
5555

5656
vulture:
5757
name: Detect dead code
@@ -64,9 +64,9 @@ jobs:
6464
- name: Setup uv
6565
uses: astral-sh/setup-uv@v7
6666
with:
67-
version: 'latest'
67+
version: "latest"
6868
enable-cache: true
69-
cache-dependency-glob: '**/pyproject.toml'
69+
cache-dependency-glob: "**/pyproject.toml"
7070

7171
- id: install-python-dependencies
7272
name: Install Python dependencies
@@ -86,7 +86,7 @@ jobs:
8686
runs-on: ubuntu-latest
8787
strategy:
8888
matrix:
89-
python: ['3.11', '3.12', '3.13', '3.14']
89+
python: ["3.11", "3.12", "3.13", "3.14"]
9090
steps:
9191
- name: Checkout
9292
uses: actions/checkout@v6
@@ -97,7 +97,7 @@ jobs:
9797
with:
9898
version: "latest"
9999
enable-cache: true
100-
cache-dependency-glob: '**/pyproject.toml'
100+
cache-dependency-glob: "**/pyproject.toml"
101101

102102
- id: install-python
103103
name: Install Python
@@ -125,7 +125,7 @@ jobs:
125125
with:
126126
version: "latest"
127127
enable-cache: true
128-
cache-dependency-glob: '**/pyproject.toml'
128+
cache-dependency-glob: "**/pyproject.toml"
129129

130130
- id: build
131131
name: Build releases

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
- id: check-ast
2121

2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.14.10
23+
rev: v0.14.13
2424
hooks:
2525
- id: ruff
2626
args: [--fix]
@@ -59,10 +59,10 @@ repos:
5959
6060
- repo: local
6161
hooks:
62-
- id: pyright
63-
name: pyright
64-
entry: uv run pyright
62+
- id: ty
63+
name: ty
64+
entry: uv run ty check
6565
language: system
6666
types: [python]
67-
exclude: tests/.*
6867
pass_filenames: false
68+
require_serial: true

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ fix: ## Auto-fix linting issues
9393
$(call banner, 🔧 Auto-fixing issues 🔧)
9494
@uv run ruff check --fix
9595

96-
type-check: ## Verify static typing with pyright
96+
type-check: ## Verify static typing with ty
9797
$(call banner, 🔍 Verifying static typing 🔍)
98-
uv run pyright
98+
uv run ty check
9999

100100
build: ## Build distribution packages
101101
$(call banner, 📦 Building distribution packages 📦)

pyproject.toml

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers = [
2424
]
2525

2626
[project.optional-dependencies]
27-
dev = ["pre-commit", "setuptools-scm", "pyright", "vulture"]
27+
dev = ["pre-commit", "setuptools-scm", "ty", "vulture"]
2828
test = [
2929
"pytest",
3030
"pytest-cov",
@@ -141,36 +141,27 @@ filterwarnings = [
141141
relative_files = true
142142
omit = ["*/__pycache__/*"]
143143

144-
[tool.pyright]
145-
pythonVersion = "3.13"
146-
venvPath = "."
147-
venv = ".venv"
148-
# include = ["your_package_name"]
149-
exclude = ["tests", "build", ".venv", "_notebooks", "**/__pycache__"]
150-
151-
# Type checking mode - "off", "basic", "standard", or "strict"
152-
typeCheckingMode = "standard"
153-
154-
# Disabled for pandas-stubs type inference issues (DataFrame/Series/ndarray ambiguity)
155-
reportMissingTypeStubs = false
156-
reportUnknownMemberType = false
157-
reportUnknownArgumentType = false
158-
reportUnknownVariableType = false
159-
reportUnknownParameterType = false
160-
reportAttributeAccessIssue = false # ndarray missing .iloc, .dt, .str, .groupby
161-
reportArgumentType = false # DataFrame vs Series parameter mismatches
162-
reportReturnType = false # DataFrame vs Series return mismatches
163-
reportCallIssue = false # No overloads for rename, concat, sort_values
164-
reportAssignmentType = false # DataFrame vs Series assignment mismatches
144+
[tool.ty.environment]
145+
python-version = "3.13"
165146

166-
# High-value type safety checks (kept enabled)
167-
reportMissingImports = true
168-
reportGeneralTypeIssues = true
169-
reportPossiblyUnboundVariable = true
170-
reportIncompatibleMethodOverride = true
171-
reportOptionalMemberAccess = true
172-
reportOptionalCall = true
173-
reportUnhashable = true
147+
[tool.ty.src]
148+
# include = ["your_package_name"]
149+
exclude = [
150+
"tests/**",
151+
"build/**",
152+
".venv/**",
153+
".github/**",
154+
".vscode/**",
155+
"**/__pycache__",
156+
]
174157

175-
# Disabled because .configure() class factory pattern requires subclasses to narrow types
176-
reportIncompatibleVariableOverride = false
158+
[tool.ty.rules]
159+
invalid-argument-type = "warn"
160+
invalid-return-type = "warn"
161+
invalid-key = "warn"
162+
invalid-assignment = "warn"
163+
invalid-method-override = "warn"
164+
unresolved-attribute = "warn"
165+
possibly-missing-attribute = "warn"
166+
no-matching-overload = "ignore"
167+
unused-ignore-comment = "ignore"

uv.lock

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

0 commit comments

Comments
 (0)