Skip to content

Commit 0fa44b8

Browse files
pre-commit-ci[bot]stickm4n
authored andcommitted
📝 Update type alias definitions in tests and compatibility module for Python 3.12
1 parent a7615de commit 0fa44b8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

‎sqlmodel/_compat.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ def partial_init() -> Generator[None, None, None]:
7474

7575

7676
if IS_PYDANTIC_V2:
77+
from typing import TypeAliasType
78+
7779
from annotated_types import MaxLen
7880
from pydantic import ConfigDict as BaseConfig
7981
from pydantic._internal._fields import PydanticMetadata
8082
from pydantic._internal._model_construction import ModelMetaclass
8183
from pydantic._internal._repr import Representation as Representation
8284
from pydantic_core import PydanticUndefined as Undefined
8385
from pydantic_core import PydanticUndefinedType as UndefinedType
84-
from typing import TypeAliasType
8586

8687
# Dummy for types, to make it importable
8788
class ModelField:

‎tests/test_field_sa_type.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,45 @@ def test_sa_type_1() -> None:
1414

1515
class Hero1(SQLModel, table=True):
1616
pk: int = Field(primary_key=True)
17-
weapon: Type1 = 'sword'
17+
weapon: Type1 = "sword"
18+
1819

1920
@pytest.mark.skipif(version_info[1] < 12, reason="Language feature of Python 3.12+")
2021
def test_sa_type_2() -> None:
2122
Type2 = Annotated[str, "Just a comment"]
2223

2324
class Hero(SQLModel, table=True):
2425
pk: int = Field(primary_key=True)
25-
weapon: Type2 = 'sword'
26+
weapon: Type2 = "sword"
27+
2628

2729
@pytest.mark.skipif(version_info[1] < 12, reason="Language feature of Python 3.12+")
2830
def test_sa_type_3() -> None:
2931
type Type3 = str
3032

3133
class Hero(SQLModel, table=True):
3234
pk: int = Field(primary_key=True)
33-
weapon: Type3 = 'sword'
35+
weapon: Type3 = "sword"
36+
3437

3538
@pytest.mark.skipif(version_info[1] < 12, reason="Language feature of Python 3.12+")
3639
def test_sa_type_4() -> None:
3740
type Type4 = Annotated[str, "Just a comment"]
3841

3942
class Hero(SQLModel, table=True):
4043
pk: int = Field(primary_key=True)
41-
weapon: Type4 = 'sword'
44+
weapon: Type4 = "sword"
45+
4246

4347
@pytest.mark.skipif(version_info[1] < 12, reason="Language feature of Python 3.12+")
4448
def test_sa_type_5() -> None:
45-
4649
class Hero(SQLModel, table=True):
4750
pk: int = Field(primary_key=True)
48-
weapon: Type5 = 'sword'
51+
weapon: Type5 = "sword"
52+
4953

5054
@pytest.mark.skipif(version_info[1] < 12, reason="Language feature of Python 3.12+")
5155
def test_sa_type_6() -> None:
5256
class Hero(SQLModel, table=True):
5357
pk: int = Field(primary_key=True)
54-
weapon: Type6 = 'sword'
58+
weapon: Type6 = "sword"

0 commit comments

Comments
 (0)