Skip to main content

type checker agnostic parallel type checking tool

Project description

typsht

type checker agnostic parallel type checking tool. run multiple python type checkers (mypy, pyright, ty, pyre) in parallel on the same code.

inspired by tox, but specifically for type checkers. get comprehensive type checking coverage by running multiple type checkers simultaneously.

installation

quick start (no installation)

use uvx to run typsht without installing it:

# check inline code
uvx typsht 'def foo(x: int) -> str: return x'

# check a file
uvx typsht --file my_module.py

install to your project

uv add typsht

usage

check inline code:

# this will catch the type error across all checkers
typsht 'def foo(x: int) -> str: return x'

check a file:

typsht --file my_module.py

run specific type checkers:

typsht --file my_module.py --checkers mypy --checkers ty

show detailed output from each checker:

typsht --file my_module.py --verbose

project support

typsht automatically detects when checking files in a uv project (containing pyproject.toml or uv.lock) and runs type checkers using uv run --project, giving them access to your local development packages.

this is useful for library developers who want to verify type annotations work across multiple checkers:

# in a project with local packages installed in editable mode
uvx typsht --file repros/test_case.py --verbose

# type checkers will have access to your local package imports

inline code always runs in an isolated environment.

pytest plugin

typsht includes a pytest plugin for running type safety tests across multiple type checkers. the key feature is inline assertions that work identically across mypy, pyright, and ty.

inline assertions (checker-agnostic)

use # R: type for reveal_type assertions and # E: pattern for error assertions:

- case: reveal_type_works_across_checkers
  checkers: [mypy, pyright, ty]
  main: |
    x: list[str] = ["a", "b"]
    reveal_type(x)  # R: list[str]

- case: error_detected_across_checkers
  checkers: [mypy, pyright, ty]
  main: |
    def foo(x: int) -> str:
        return x  # E: return

the plugin normalizes type representations (builtins.int -> int, List -> list, Literal[42] -> int) so the same assertion works across all checkers.

legacy format (pytest-mypy-plugins compatible)

also supports the pytest-mypy-plugins format for migrating existing tests:

- case: mypy_specific_output
  main: |
    x: int = 42
    reveal_type(x)
  out: 'Revealed type is "builtins.int"'

- case: should_pass_check
  main: |
    def add(a: int, b: int) -> int:
        return a + b
  should_pass: true

run the tests:

pytest tests/typesafety/

programmatic assertions

for python tests, use the assertion helpers directly:

from typsht import assert_type_equals, assert_type_error, assert_no_errors, CheckerType

def test_reveal_type():
    assert_type_equals('''
        x: int = 1
        reveal_type(x)
    ''', line=2, expected_type="int", checkers=[CheckerType.MYPY, CheckerType.PYRIGHT, CheckerType.TY])

def test_catches_error():
    assert_type_error('''
        def foo(x: int) -> str:
            return x
    ''', error_pattern="return", checkers=[CheckerType.MYPY, CheckerType.PYRIGHT, CheckerType.TY])

def test_valid_code():
    assert_no_errors('''
        def add(a: int, b: int) -> int:
            return a + b
    ''', checkers=[CheckerType.MYPY, CheckerType.PYRIGHT, CheckerType.TY])

supported type checkers

by default, typsht runs:

  • mypy - widely adopted static type checker
  • pyright - fast static type checker from microsoft
  • ty - experimental blazing-fast type checker

also available (requires project configuration):

  • pyre - facebook's type checker (requires .pyre_configuration)

development

install dependencies:

uv sync

run tests:

uv run pytest

install pre-commit hooks:

uv run pre-commit install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typsht-0.0.1a3.tar.gz (52.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typsht-0.0.1a3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file typsht-0.0.1a3.tar.gz.

File metadata

  • Download URL: typsht-0.0.1a3.tar.gz
  • Upload date:
  • Size: 52.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.23 {"installer":{"name":"uv","version":"0.9.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for typsht-0.0.1a3.tar.gz
Algorithm Hash digest
SHA256 3448b3a9bfec9cc5392caa5accf88b916eca2e71dee9bd9819058236ee49b345
MD5 a3909f9d137b6063bff4f98a17cbbf62
BLAKE2b-256 02028c7b3e8c4880cb1d83f91faaad7d81c1698ace12fc571f3a9d0da5049e0c

See more details on using hashes here.

File details

Details for the file typsht-0.0.1a3-py3-none-any.whl.

File metadata

  • Download URL: typsht-0.0.1a3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.23 {"installer":{"name":"uv","version":"0.9.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for typsht-0.0.1a3-py3-none-any.whl
Algorithm Hash digest
SHA256 195ec1a4d1aa3a2b1b0689b8d329297fa3ea9fc6bf9f07a9facb9f47ff83d557
MD5 2a66dba9ded2a7c6d541bff439bc8e41
BLAKE2b-256 5764ec3e842127c296acc086ba7009462b3cd8a7b75b927aad20de3468f01759

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page