Skip to content

Commit 29662e3

Browse files
committed
feat: change to ty instead of basedpyright
1 parent 9fb4626 commit 29662e3

41 files changed

Lines changed: 175 additions & 410 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "dev",
2+
"name": "openapi-python-dev",
33
"dockerComposeFile": [
44
"docker-compose.yml"
55
],
6-
"service": "dev",
6+
"service": "openapi-python-dev",
77
"workspaceFolder": "/code",
88
"overrideCommand": true,
99
"postCreateCommand": "prek install",
@@ -14,12 +14,12 @@
1414
"openai.chatgpt",
1515
// Python dev
1616
"charliermarsh.ruff",
17-
"detachhead.basedpyright",
17+
"astral-sh.ty",
1818
"tamasfe.even-better-toml"
1919
],
2020
"settings": {
2121
"terminal.integrated.shell.linux": "/bin/bash"
2222
}
2323
}
2424
}
25-
}
25+
}

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
2-
dev:
2+
openapi-python-dev:
33
build:
44
context: ../
55
dockerfile: .devcontainer/Dockerfile

.github/workflows/qa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: uv run ruff format --check .
3434

3535
- name: Type check package
36-
run: uv run basedpyright -p pyproject.toml
36+
run: uv run ty check .
3737

3838
- name: Contract tests
3939
run: uv run pytest -n auto

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
run: uv run ruff format --check .
7575

7676
- name: Type check package
77-
run: uv run basedpyright -p pyproject.toml
77+
run: uv run ty check .
7878

7979
- name: Contract tests
8080
run: uv run pytest tests/test_contracts.py -n auto

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
- id: type check
2929
name: type check
3030
language: system
31-
entry: uv run basedpyright .
31+
entry: uv run ty check .
3232
pass_filenames: false
3333
priority: 1
3434

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"editor.quickSuggestions": {
44
"strings": true
55
},
6-
// API
76
"[python]": {
87
"editor.tabSize": 4,
98
"editor.defaultFormatter": "charliermarsh.ruff",

openapi_python/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TypeVar, overload
3+
from typing import TypeVar, cast, overload
44

55
_T = TypeVar("_T")
66

@@ -19,9 +19,10 @@ def safe_get(
1919
current = obj
2020
for part in path:
2121
if isinstance(current, dict):
22-
if part not in current:
22+
current_dict = cast(dict[str | int, object], current)
23+
if part not in current_dict:
2324
return None
24-
current = current[part]
25+
current = current_dict[part]
2526
continue
2627

2728
if isinstance(current, list) and isinstance(part, int):

pyproject.toml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ openapi-python = "openapi_python.cli:main"
3434

3535
[dependency-groups]
3636
dev = [
37-
"basedpyright>=1.39.3",
3837
"fastapi>=0.115.12",
3938
"httpx>=0.28.1",
4039
"pytest>=8.3.5",
@@ -43,6 +42,7 @@ dev = [
4342
"python-multipart>=0.0.20",
4443
"ruff>=0.9.10",
4544
"twine>=6.1.0",
45+
"ty>=0.0.34",
4646
"uvicorn>=0.34.0",
4747
]
4848

@@ -53,15 +53,16 @@ package = true
5353
ignore = ["E712"]
5454
extend-select = ["I"]
5555

56-
[tool.pyright]
57-
include = ["./openapi_python/**/*.py"]
58-
typeCheckingMode = "standard"
59-
reportMissingImports = true
60-
reportUnusedVariable = true
61-
reportOptionalSubscript = true
62-
reportOptionalMemberAccess = true
63-
reportOptionalCall = true
64-
pythonVersion = "3.12"
56+
[tool.ty.src]
57+
include = ["**/*.py"]
58+
exclude = ["**/__pycache__/", ".venv/", "**/generated/"]
59+
60+
[tool.ty.environment]
61+
python = ".venv"
62+
python-version = "3.12"
63+
64+
[tool.ty.rules]
65+
unresolved-import = "error"
6566

6667
[tool.pytest.ini_options]
6768
testpaths = ["tests"]

pyrightconfig.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

scripts/release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def main() -> None:
105105

106106
run(["uv", "run", "ruff", "check", "--select", "I", "."])
107107
run(["uv", "run", "ruff", "format", "--check", "."])
108-
run(["uv", "run", "basedpyright", "-p", "pyproject.toml"])
108+
run(["uv", "run", "ty", "check", "."])
109109
run(["uv", "run", "pytest", "-n", "auto"])
110110
run(["uv", "build"])
111111

0 commit comments

Comments
 (0)