Using sa_type causes Mypy type error #955
Unanswered
vinodkumars
asked this question in
Questions
Replies: 3 comments 1 reply
-
I also faced the same problem. Are there any solutions? I use |
Beta Was this translation helpful? Give feedback.
0 replies
-
Same basic thing with pyright:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
It seems that you should use from typing import Optional
from datetime import datetime
from sqlmodel import Column, DateTime, Field, SQLModel, func
class DateTimeTest(SQLModel):
__tablename__ = "date_time_test"
created_at: Optional[datetime] = Field(
sa_column=Column(DateTime(timezone=True), server_default=func.now())
) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
Creating a column with sa_type causes a type error with Mypy. Here is the error:
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.18
Python Version
3.11.8
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions