|
6 | 6 | from enum import Enum |
7 | 7 | from pathlib import Path |
8 | 8 | from typing import ( |
9 | | - TYPE_CHECKING, |
10 | 9 | AbstractSet, |
11 | 10 | Any, |
12 | 11 | Callable, |
|
24 | 23 | cast, |
25 | 24 | ) |
26 | 25 |
|
27 | | -from pydantic import BaseModel |
| 26 | +from pydantic import BaseConfig, BaseModel |
28 | 27 | from pydantic.errors import ConfigError, DictError |
29 | 28 | from pydantic.fields import FieldInfo as PydanticFieldInfo |
30 | 29 | from pydantic.fields import ModelField, Undefined, UndefinedType |
31 | | -from pydantic.main import BaseConfig, ModelMetaclass, validate_model |
| 30 | +from pydantic.main import ModelMetaclass, validate_model |
32 | 31 | from pydantic.typing import ForwardRef, NoArgAnyCallable, resolve_annotations |
33 | 32 | from pydantic.utils import ROOT_KEY, Representation |
34 | 33 | from sqlalchemy import ( |
@@ -453,7 +452,7 @@ def get_column_from_field(field: ModelField) -> Column: # type: ignore |
453 | 452 | sa_column_kwargs = getattr(field.field_info, "sa_column_kwargs", Undefined) |
454 | 453 | if sa_column_kwargs is not Undefined: |
455 | 454 | kwargs.update(cast(Dict[Any, Any], sa_column_kwargs)) |
456 | | - return Column(sa_type, *args, **kwargs) |
| 455 | + return Column(sa_type, *args, **kwargs) # type: ignore |
457 | 456 |
|
458 | 457 |
|
459 | 458 | class_registry = weakref.WeakValueDictionary() # type: ignore |
@@ -494,9 +493,6 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Any: |
494 | 493 | def __init__(__pydantic_self__, **data: Any) -> None: |
495 | 494 | # Uses something other than `self` the first arg to allow "self" as a |
496 | 495 | # settable attribute |
497 | | - if TYPE_CHECKING: |
498 | | - __pydantic_self__.__dict__: Dict[str, Any] = {} |
499 | | - __pydantic_self__.__fields_set__: Set[str] = set() |
500 | 496 | values, fields_set, validation_error = validate_model( |
501 | 497 | __pydantic_self__.__class__, data |
502 | 498 | ) |
@@ -608,7 +604,7 @@ def validate(cls: Type["SQLModel"], value: Any) -> "SQLModel": |
608 | 604 | return cls(**value_as_dict) |
609 | 605 |
|
610 | 606 | # From Pydantic, override to only show keys from fields, omit SQLAlchemy attributes |
611 | | - def _calculate_keys( # type: ignore |
| 607 | + def _calculate_keys( |
612 | 608 | self, |
613 | 609 | include: Optional[Mapping[Union[int, str], Any]], |
614 | 610 | exclude: Optional[Mapping[Union[int, str], Any]], |
|
0 commit comments