Registry / type-stubs / types-typed-ast

types-typed-ast

JSON →
library1.5.8.7pypypiunverified

types-typed-ast provides static type annotations (stubs) for the `typed-ast` library, enabling type checkers like MyPy to understand its API and catch type-related errors. It is part of the `typeshed` project, a community-maintained repository of type stubs for Python packages. The current version is 1.5.8.7, and `typeshed` releases new stubs regularly as upstream libraries evolve.

pip install types-typed-ast
INSTALL
IMPORT
SIG · TYPES-TYPED-AST
T
types-typed-ast
type-stubspythonv1.5.8.7
Install
2.6s avg
Import
Disk
119MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.8.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 2.55s
py 3.11
✓ —
✓ 2.49s
py 3.12
4/8 runs
4/8 runs
py 3.13
4/8 runs
4/8 runs
py 3.9
✓ —
✓ 2.88s
119MB installed
● package 119MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AST
from typed_ast_stubs.ast3 import AST
from typed_ast_stubs.ast3 import AST

This example demonstrates how to use `typed-ast` (the runtime library) and how `types-typed-ast` (the stub package) provides type hints for it. The `mypy` command would use the installed stubs to verify type correctness of `analyze_node`'s arguments and return types without any explicit import of `types-typed-ast`.

import typed_ast.ast3 as typed_ast def analyze_node(node: typed_ast.AST) -> str: """Analyzes an AST node and returns its type name.""" if isinstance(node, typed_ast.Expr): return f"Expression node: {typed_ast.dump(node)}" return f"Generic node: {type(node).__name__}" source_code = "def example_func(a: int, b: int) -> int: return a + b" parsed_module = typed_ast.parse(source_code, mode='exec') # This call is type-checked by MyPy using the stubs provided by types-typed-ast result = analyze_node(parsed_module) print(result) # To run type checking, save this as 'my_script.py' and run: # mypy my_script.py
Debug
Known issues
gotchaStub packages like `types-typed-ast` provide *only* type information and are not intended for direct import or runtime execution. Attempting to `import types_typed_ast` will result in a `ModuleNotFoundError`.
fix
Always import symbols from the *runtime library* (`typed-ast`), not the stub package. The stub package is consumed implicitly by type checkers like MyPy.
affects: All versions
gotchaFor `types-typed-ast` to be effective, the actual runtime library `typed-ast` must also be installed. The stubs don't provide the implementation, only the type signatures.
fix
Ensure both `pip install typed-ast` and `pip install types-typed-ast` are executed. `typed-ast` for runtime, `types-typed-ast` for type checking.
affects: All versions
gotchaVersion compatibility between stub packages and their corresponding runtime libraries can be an issue. Stubs are generated for specific versions of the runtime, and mismatches can lead to incorrect type checking results or missing definitions.
fix
When encountering unexpected type errors, ensure your `types-typed-ast` version is compatible with your `typed-ast` version. Consult the `typeshed` repository or `typed-ast` documentation for compatibility notes. Upgrading both packages might resolve the issue.
affects: All versions
Upgrade
Version history
1.5.8.7latest on PyPI · released Jul 5, 2023
Audit
Dependencies
typed-astrequiredProvides the runtime functionality for which these stubs are created.
mypyoptionalA common static type checker that utilizes these stubs.
Agent activity
43 hits · last 30 days
node
39
OpenAI (training)
2
Resources
types-typed-ast — pip install types-typed-ast · libregistry