Skip to content

Expose all pydantic_ai.messages types on pydantic_ai to aid IDE auto-import #2931

@moritzwilksch

Description

@moritzwilksch

Question

pydantic_ai/__init__.py exposes a seemingly random subset of types by setting the modules __all__ attribute. Since the list is not exhaustive of all elements, this messes with my type checker and IDE auto-imports. What is the rationale behind the selected items? Is the list outdated and could it be changed or expanded?

Usually, we'd use this for more convenient, less deep import chains, e.g. from pydantic_ai import ToolDefinition, but other dev tooling doesn't seem to like this exposing of a subset of types.

Example

ToolDefinition is exposed here, so a type checker can find it:

Image

ModelRequest is not exposed, so no auto-import available and some type checkers can complain:

Image

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions