-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Labels
libraryDedicated support for popular third-party librariesDedicated support for popular third-party libraries
Description
Summary
When a SQLModel table class has a field with Field(primary_key=True), SQLModel makes that field optional in __init__ (the database auto-generates it).
ty incorrectly reports missing-argument because it doesn't recognize that primary_key=True changes the field's optionality.
Minimal repro
from sqlmodel import Field, SQLModel
class Item(SQLModel, table=True):
id: int = Field(primary_key=True)
name: str = Field(default="test")
# This is valid — SQLModel makes `id` optional because it's a primary key.
# At runtime, the database auto-generates the id.
item = Item()Then
ty check .Expected
No error. Item() is valid because primary_key=True makes id optional in the constructor (both mypy and pyright pass, and it works at runtime).
Actual
error[missing-argument]: No argument provided for required parameter `id`
Environment
- ty 0.0.18
- SQLModel 0.0.27
- Python 3.13
Version
ty 0.0.18
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
libraryDedicated support for popular third-party librariesDedicated support for popular third-party libraries