Skip to content

Commit 60181e6

Browse files
👷 Run mypy by pre-commit (#1738)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 7f0f234 commit 60181e6

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ repos:
2828
language: unsupported
2929
types: [python]
3030

31+
- id: local-mypy
32+
name: mypy check
33+
entry: uv run mypy sqlmodel tests/test_select_typing.py
34+
require_serial: true
35+
language: unsupported
36+
pass_filenames: false
37+
3138
- id: generate-select
3239
language: unsupported
3340
name: generate-select

sqlmodel/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ def __new__(
579579
config_kwargs = {
580580
key: kwargs[key] for key in kwargs.keys() & allowed_config_kwargs
581581
}
582-
new_cls = super().__new__(cls, name, bases, dict_used, **config_kwargs)
582+
new_cls = cast(
583+
"SQLModel", super().__new__(cls, name, bases, dict_used, **config_kwargs)
584+
)
583585
new_cls.__annotations__ = {
584586
**relationship_annotations,
585587
**pydantic_annotations,
@@ -607,10 +609,10 @@ def get_config(name: str) -> Any:
607609
# This could be done by reading new_cls.model_config['table'] in FastAPI, but
608610
# that's very specific about SQLModel, so let's have another config that
609611
# other future tools based on Pydantic can use.
610-
new_cls.model_config["read_from_attributes"] = True
612+
new_cls.model_config["read_from_attributes"] = True # type: ignore[typeddict-unknown-key]
611613
# For compatibility with older versions
612614
# TODO: remove this in the future
613-
new_cls.model_config["read_with_orm_mode"] = True
615+
new_cls.model_config["read_with_orm_mode"] = True # type: ignore[typeddict-unknown-key]
614616

615617
config_registry = get_config("registry")
616618
if config_registry is not Undefined:
@@ -792,7 +794,7 @@ def get_column_from_field(field: Any) -> Column: # type: ignore
792794
)
793795
if sa_column_kwargs is not Undefined:
794796
kwargs.update(cast(dict[Any, Any], sa_column_kwargs))
795-
return Column(sa_type, *args, **kwargs) # type: ignore
797+
return Column(sa_type, *args, **kwargs)
796798

797799

798800
class_registry = weakref.WeakValueDictionary() # type: ignore

0 commit comments

Comments
 (0)