FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

馃悰 Make generics work with SQLModel as base class by ryangalamb 路 Pull Request #1275 路 fastapi/sqlmodel 路 GitHub

Repository navigation

馃悰 Make generics work with SQLModel as base class - #1275

Open
ryangalamb wants to merge 10 commits into
fastapi:mainfrom
ryangalamb:rjmill/fix-generic
Open

ryangalamb wants to merge 10 commits into
fastapi:mainfrom
ryangalamb:rjmill/fix-generic

Conversation

ryangalamb commented Jan 24, 2025 •
edited by YuriiMotov
Loading

Copy link
Copy Markdown

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)

Related discussions:

This comment was marked as resolved.

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

Copy link
Copy Markdown
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 馃檹

YuriiMotov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

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

Code and tests look good!

github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 3, 2026

This comment was marked as resolved.

github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Feb 3, 2026
Refactor type hints to use built-in list instead of List from typing.
Removed the @needs_pydanticv2 decorator from test functions.

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL