Skip to content

Ty misses required-field diagnostic for SQLModel (works for BaseModel) #1329

@Duckling92

Description

@Duckling92

Summary

Ty flags missing required fields for pydantic.BaseModel but not for sqlmodel.SQLModel subclasses, both using Pydantic v2.

Minimal repro

from __future__ import annotations

from pydantic import BaseModel
from sqlmodel import SQLModel


class ExamplePydantic(BaseModel):
    number: float


class ExampleSQLModel(SQLModel):
    number: float


ExampleSQLModel()  # ty: no error (bug)
ExamplePydantic()  # ty: error (good)

Expected

Expected: Both ExampleSQLModel() and ExamplePydantic() are flagged as missing required field number.
Actual: Only ExamplePydantic() is flagged, ExampleSQLModel() passes.

Environment

python: 3.11.10
sqlmodel: 0.0.27
OS: MacOS Tahoe (26.0.1)

Version

ty 0.0.1-alpha.21 (ef52a19 2025-09-19)

Metadata

Metadata

Assignees

No one assigned

    Labels

    libraryDedicated support for popular third-party libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions