typeshed-client is a Python library (version 2.9.0) for programmatically accessing type stubs from typeshed and PEP 561 stub packages. It allows tools to find stub files, discover names defined in stubs, and retrieve AST nodes for definitions. The library frequently updates its bundled typeshed to stay current with the official type stub repository.
pip install typeshed-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to find a stub file for a given module, retrieve its Abstract Syntax Tree (AST), and how to customize the stub search behavior using a `SearchContext`. It shows fetching stubs for 'typing' and attempts for 'math'.
Upgrade your Python interpreter to version 3.9 or a later supported version.
Upgrade your Python interpreter to version 3.8 or later.
Update any code that directly interacts with the AST parsing to use `ast` module compatible structures and features.
Avoid using `get_search_path()`. Instead, configure the `search_path` directly when creating a `SearchContext` if custom paths are needed.
Upgrade to `typeshed-client` version 2.8.0 or newer to benefit from improved encoding handling on Windows.
If you experience unexpected resolution, explicitly set `allow_py_files=False` in your `SearchContext` or review your stub package structure.
pip install typeshed-client
from typeshed_client import finder
finder.get_stub_names('builtins')from typeshed_client import finder
finder.get_stub_names('builtins', version=(3, 9))from typeshed_client import finder
finder.get_stub_names('os')