Skip to content

Conversation

@ryangalamb
Copy link

Generics, as documented in pydantic's docs do not work.

Repro: Use the example from pydantic's docs. The typevar type does not get validated.

For example: Response[int](data="not an int") does not raise an error.

Furthermore, json schema generation is broken, as described here: #1002

This PR:

  • fixes generics, so they actually validate (instead of silently passing)
  • includes thorough tests (based on an example from pydantic's docs)

@ryangalamb

This comment was marked as resolved.

@svlandeg svlandeg added the feature New feature or request label Feb 20, 2025
@svlandeg svlandeg added bug Something isn't working and removed feature New feature or request labels Feb 20, 2025
@svlandeg svlandeg changed the title fix: make generics work with SQLModel as base class 🐛 Make generics work with SQLModel as base class Feb 20, 2025
@svlandeg
Copy link
Member

Thanks for the contribution! We're currently trying to catch up with the backlog of PRs, and will get back to you once we've had time to review this 🙏

Copy link
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Not completely understand how it works that __pydantic_** are injected into kwargs, but the fix works!

Code and tests look good!

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants