Skip to content

Commit 8a64d26

Browse files
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
1 parent 43878b5 commit 8a64d26

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sqlmodel/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
cast,
2727
overload,
2828
)
29+
from typing import Annotated as TypingAnnotated
2930

3031
from pydantic import BaseModel, EmailStr
3132
from pydantic.fields import FieldInfo as PydanticFieldInfo
@@ -56,13 +57,16 @@
5657
from sqlalchemy.sql.sqltypes import LargeBinary, Time, Uuid
5758
from typing_extensions import (
5859
Annotated as TEAnnotated,
60+
)
61+
from typing_extensions import (
5962
Literal,
6063
TypeAlias,
6164
deprecated,
62-
get_args as te_get_args,
6365
get_origin,
6466
)
65-
from typing import Annotated as TypingAnnotated
67+
from typing_extensions import (
68+
get_args as te_get_args,
69+
)
6670

6771
from ._compat import ( # type: ignore[attr-defined]
6872
IS_PYDANTIC_V2,
@@ -568,7 +572,7 @@ def __new__(
568572
# Attach found Column to the Pydantic field info
569573
model_fields = get_model_fields(new_cls)
570574
if field_name in model_fields:
571-
setattr(model_fields[field_name], "sa_column", sa_col)
575+
model_fields[field_name].sa_column = sa_col
572576
break
573577
except Exception:
574578
# Best-effort; fall back to default behavior

tests/test_field_sa_column.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
from typing import Optional
21
from datetime import datetime
3-
from typing_extensions import Annotated
2+
from typing import Optional
43

54
import pytest
6-
from sqlalchemy import Column, Integer, String, DateTime
5+
from sqlalchemy import Column, DateTime, Integer, String
76
from sqlmodel import Field, SQLModel
7+
from typing_extensions import Annotated
8+
89
from tests.conftest import needs_pydanticv2
910

1011

0 commit comments

Comments
 (0)