Skip to content

Commit 8d1b6f0

Browse files
authored
⬆ Upgrade mypy, fix type annotations (#218)
1 parent 7fcd4fd commit 8d1b6f0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true}
3737

3838
[tool.poetry.dev-dependencies]
3939
pytest = "^6.2.4"
40-
mypy = "^0.910"
40+
mypy = "0.930"
4141
flake8 = "^3.9.2"
4242
black = {version = "^21.5-beta.1", python = "^3.7"}
4343
mkdocs = "^1.2.1"

sqlmodel/main.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from enum import Enum
77
from pathlib import Path
88
from typing import (
9-
TYPE_CHECKING,
109
AbstractSet,
1110
Any,
1211
Callable,
@@ -24,11 +23,11 @@
2423
cast,
2524
)
2625

27-
from pydantic import BaseModel
26+
from pydantic import BaseConfig, BaseModel
2827
from pydantic.errors import ConfigError, DictError
2928
from pydantic.fields import FieldInfo as PydanticFieldInfo
3029
from pydantic.fields import ModelField, Undefined, UndefinedType
31-
from pydantic.main import BaseConfig, ModelMetaclass, validate_model
30+
from pydantic.main import ModelMetaclass, validate_model
3231
from pydantic.typing import ForwardRef, NoArgAnyCallable, resolve_annotations
3332
from pydantic.utils import ROOT_KEY, Representation
3433
from sqlalchemy import (
@@ -453,7 +452,7 @@ def get_column_from_field(field: ModelField) -> Column: # type: ignore
453452
sa_column_kwargs = getattr(field.field_info, "sa_column_kwargs", Undefined)
454453
if sa_column_kwargs is not Undefined:
455454
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
457456

458457

459458
class_registry = weakref.WeakValueDictionary() # type: ignore
@@ -494,9 +493,6 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Any:
494493
def __init__(__pydantic_self__, **data: Any) -> None:
495494
# Uses something other than `self` the first arg to allow "self" as a
496495
# settable attribute
497-
if TYPE_CHECKING:
498-
__pydantic_self__.__dict__: Dict[str, Any] = {}
499-
__pydantic_self__.__fields_set__: Set[str] = set()
500496
values, fields_set, validation_error = validate_model(
501497
__pydantic_self__.__class__, data
502498
)
@@ -608,7 +604,7 @@ def validate(cls: Type["SQLModel"], value: Any) -> "SQLModel":
608604
return cls(**value_as_dict)
609605

610606
# From Pydantic, override to only show keys from fields, omit SQLAlchemy attributes
611-
def _calculate_keys( # type: ignore
607+
def _calculate_keys(
612608
self,
613609
include: Optional[Mapping[Union[int, str], Any]],
614610
exclude: Optional[Mapping[Union[int, str], Any]],

0 commit comments

Comments
 (0)