Skip to content

Conversation

moritzwilksch
Copy link
Contributor

@moritzwilksch moritzwilksch commented Sep 18, 2025

Fixes #2940

Running this on the example from the issue works:

(pydantic-ai) ➜  pydantic-ai git:(mw/invarinat-typing-v2) ✗ uv run pyright mre.py

0 errors, 0 warnings, 0 informations

@DouweM
Copy link
Collaborator

DouweM commented Sep 18, 2025

@moritzwilksch Thanks for filing this. I think some of these changes are good, but many of them are unfortunately breaking changes (which we can't make until v2), as users may be treating the results of these methods and fields as a list, which it is now no longer guaranteed to be. It would also cause issues for people implementing their own Model subclass with an override for the request method with takes a messages argument that went from list to Sequence, as they'd now get type errors at the very least (invalid method override) and errors at worst (if they were treating it as a list). Same for people subclassing AbstractAgent and overriding the iter/run methods that take message_history.

Note that someone ran into issues because of #2797 as well: https://pydanticlogfire.slack.com/archives/C083V7PMHHA/p1757772153719419, but that was fine as it was pre-v1.

So I think we should reduce this to the smallest possible diff that addresses the user-facing issue you described in #2940, and then determine whether that would be a breaking change or not.

Copy link

This PR is stale, and will be closed in 3 days if no reply is received.

@github-actions github-actions bot added the Stale label Sep 26, 2025
Copy link

Closing this PR as it has been inactive for 10 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More invariant typing problems
2 participants