ty-types

raw JSON →
0.0.31 verified Fri May 01 auth: no python

A CLI tool and JSON-RPC server that exposes Python type inference from the 'ty' library. It provides structured type descriptors, callable signature extraction, and support for generics, TypeVar bounds, and ParamSpec. Current version 0.0.31, updated frequently.

pip install ty-types
error ModuleNotFoundError: No module named 'ty_types.ide_support'
cause The `ide_support` module was removed in v0.0.19, replaced by `direct_call`.
fix
Change import to from ty_types.direct_call import ... or use top-level exports.
error AttributeError: 'TypeDescriptor' object has no attribute 'type_parameters'
cause Serialization format changed; type parameters are now in `typeParameters` field.
fix
Access typeParameters instead of type_parameters on serialized dict.
deprecated The old `ide_support` module has been removed; use `direct_call` bindings instead.
fix Replace any imports from `ty_types.ide_support` with `ty_types.direct_call`.
breaking Generic descriptors now always serialize type parameters; serialization format changed in 0.0.19.
fix Update consumers of serialized type data to expect `typeParameters` field always present (even if empty).
gotcha The JSON-RPC server requires Python 3.8 or later; some advanced type features (like ParamSpec) need Python 3.10+.
fix Ensure runtime environment matches Python version requirements in your project.

Quickstart: import TypeDescriptor and infer types. Also see CLI: `ty-types` command.

from ty_types import TypeDescriptor
import os

# Infer type of a Python expression
expr = '1 + 2'
# Replace with actual source code or file path
td = TypeDescriptor(expr)
# The descriptor will fetch type from 'ty' library
print(td)
# For JSON-RPC server, use: python -m ty_types.server