Loading...
Loading...
Python type checking expertise using ty - the extremely fast type checker by Astral. Use when: (1) Adding type annotations to Python code, (2) Fixing type errors reported by ty, (3) Migrating from mypy/pyright to ty, (4) Configuring ty for projects, (5) Understanding advanced type patterns (generics, protocols, intersection types), (6) Setting up ty in editors (VS Code, Cursor, Neovim, PyCharm).
npx skill4agent add jiatastic/open-python-skills ty-skills# Install
uv tool install ty
# or: pip install ty
# Check current directory
ty check
# Check specific files
ty check src/
# Full diagnostics
ty check --output-format fullpyproject.toml[tool.ty.environment]
python-version = "3.12"
python = "./.venv"
python-platform = "linux"
root = ["./src"]
extra-paths = ["./typings"]
[tool.ty.rules]
# error: fail CI, warn: report, ignore: disable
possibly-unresolved-reference = "error"
invalid-argument-type = "error"
division-by-zero = "warn"
unused-ignore-comment = "warn"
[tool.ty.src]
include = ["src", "tests"]
exclude = ["src/migrations/"]
# Per-file overrides
[[tool.ty.overrides]]
include = ["tests/**"]
[tool.ty.overrides.rules]
possibly-unresolved-reference = "warn"| Rule | Default | Description |
|---|---|---|
| error | Variable might not be defined |
| error | Argument type mismatch |
| error | Assigned value incompatible |
| error | Required argument missing |
| error | Operator not supported for types |
| error | Return type mismatch |
| warn | Potential division by zero |
| warn | Suppression not needed |
| warn | Cast has no effect |
| warn | Attribute might not exist |
| warn | Index might be out of range |
def output_as_json(obj: Serializable) -> str:
if isinstance(obj, Versioned):
reveal_type(obj) # reveals: Serializable & Versioned
return str({
"data": obj.serialize_json(), # From Serializable
"version": obj.version # From Versioned
})
return obj.serialize_json()# Suppress single rule
x: int = "hello" # type: ignore[incompatible-assignment]
# Suppress multiple
y = risky() # type: ignore[possibly-unresolved-reference, invalid-argument-type]| Document | Content |
|---|---|
| All rules with examples and fixes |
| Python typing module quick reference |
| Protocols, generics, type guards, variance |
| mypy/pyright → ty migration |
| Error solutions with examples |
| VS Code, Cursor, Neovim setup |