Skip to content

Commit 1fc1717

Browse files
committed
simply import Literal from typing_extensions always
1 parent 545a55a commit 1fc1717

File tree

4 files changed

+3
-12
lines changed

4 files changed

+3
-12
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ disallow_untyped_defs = false
109109
disallow_untyped_calls = false
110110

111111
[tool.ruff.lint]
112-
typing-modules = ["sqlmodel._compat"]
113112
select = [
114113
"E", # pycodestyle errors
115114
"W", # pycodestyle warnings

sqlmodel/_compat.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import types
32
from contextlib import contextmanager
43
from contextvars import ContextVar
@@ -22,7 +21,7 @@
2221
from pydantic import VERSION as P_VERSION
2322
from pydantic import BaseModel
2423
from pydantic.fields import FieldInfo
25-
from typing_extensions import Annotated, get_args, get_origin
24+
from typing_extensions import Annotated, Literal, get_args, get_origin
2625

2726
from .sql.sqltypes import AutoString
2827

@@ -65,12 +64,6 @@ def _is_union_type(t: Any) -> bool:
6564
return t is UnionType or t is Union
6665

6766

68-
if sys.version_info >= (3, 9):
69-
from typing import Literal
70-
else:
71-
from typing_extensions import Literal
72-
73-
7467
finish_init: ContextVar[bool] = ContextVar("finish_init", default=True)
7568

7669

sqlmodel/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@
5353
from sqlalchemy.orm.instrumentation import is_instrumented
5454
from sqlalchemy.sql.schema import MetaData
5555
from sqlalchemy.sql.sqltypes import LargeBinary, Time, Uuid
56-
from typing_extensions import TypeAlias, deprecated, get_origin
56+
from typing_extensions import Literal, TypeAlias, deprecated, get_origin
5757

5858
from ._compat import ( # type: ignore[attr-defined]
5959
IS_PYDANTIC_V2,
6060
PYDANTIC_MINOR_VERSION,
6161
BaseConfig,
62-
Literal,
6362
ModelField,
6463
ModelMetaclass,
6564
Representation,

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sqlalchemy.exc import IntegrityError
55
from sqlalchemy.orm import RelationshipProperty
66
from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
7-
from sqlmodel._compat import Literal
7+
from typing_extensions import Literal
88

99

1010
def test_should_allow_duplicate_row_if_unique_constraint_is_not_passed(clear_sqlmodel):

0 commit comments

Comments
 (0)