Pycharm unexpected type(s) for date field #848
-
First Check
Commit to Help
Example Codeclass Hero(SQLModel, table=True):
__tablename__ = "hero"
created_date: date = Field(default_factory=lambda: datetime.now(UTC).date())
def get_min_created_date() -> date:
with get_session() as session:
query = select(Hero.created_date).where(Statistic.id == 1)
created_date = session.exec(query).first() DescriptionHi, pycharm complains about unexpected type when I select fields of date type.
![]() ![]() Operating SystemmacOS Operating System DetailsNo response SQLModel Version0.0.16 Python Version3.12 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
but works great with datetime field |
Beta Was this translation helpful? Give feedback.
-
any updates ? |
Beta Was this translation helpful? Give feedback.
-
From the source code _TScalar_0 = TypeVar(
"_TScalar_0",
Column, # type: ignore
Sequence, # type: ignore
Mapping, # type: ignore
UUID,
datetime,
float,
int,
bool,
bytes,
str,
None,
) You can see that |
Beta Was this translation helpful? Give feedback.
-
Use query = select(col(Hero.created_date)) ![]() ![]() |
Beta Was this translation helpful? Give feedback.
Use
col()
: