Type checking

We use ty for static type checking. ty is configured in the [tool.ty] section of pyproject.toml.

Running ty

To check for type errors, run:

pixi run typecheck

The same task is run by the typecheck pre-commit hook.

Rule overrides

Rule-specific, per-file exceptions are configured with [[tool.ty.overrides]] entries. Default rules remain enabled everywhere else. Prefer fixing typing issues, and remove files or rules from these overrides when they are no longer needed. Do not add global rule suppressions.

Suppressing individual errors

For specific lines where the type checker is wrong, use a targeted ignore comment:

x = some_expression  # ty: ignore[error-code]

For lines that would exceed 120 characters with the comment appended, place the comment on the line above:

# ty: ignore[error-code]
x = some_very_long_expression_that_would_be_too_long_with_an_inline_comment