From cbf9f506760d427093d7015d22c00119844b2208 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Tue, 3 Feb 2026 06:46:18 +0100 Subject: [PATCH 1/5] Run mypy by pre-commit --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 41c64c030c..8558cc0fe3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,14 @@ repos: language: unsupported types: [python] + - id: local-mypy + name: mypy check + entry: uv run mypy sqlmodel tests/test_select_typing.py + require_serial: true + language: unsupported + pass_filenames: false + types: [python] + - id: generate-select language: unsupported name: generate-select From 6cebb5503e6551e65c2aa312d10a0fbed628f02b Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Tue, 3 Feb 2026 06:49:29 +0100 Subject: [PATCH 2/5] Fix mypy warning in `main.py` --- sqlmodel/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index b0e88fd04e..98b17a237e 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -607,7 +607,7 @@ def get_config(name: str) -> Any: # This could be done by reading new_cls.model_config['table'] in FastAPI, but # that's very specific about SQLModel, so let's have another config that # other future tools based on Pydantic can use. - new_cls.model_config["read_from_attributes"] = True + new_cls.model_config["read_from_attributes"] = True # type: ignore[typeddict-unknown-key] # For compatibility with older versions # TODO: remove this in the future new_cls.model_config["read_with_orm_mode"] = True From 8604d07150b9ae0a0c4f70ef63d4949a1e56f0a0 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Tue, 3 Feb 2026 06:51:14 +0100 Subject: [PATCH 3/5] Fix other mypy warnings in `main.py` --- sqlmodel/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 98b17a237e..5912572f4c 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -579,7 +579,10 @@ def __new__( config_kwargs = { key: kwargs[key] for key in kwargs.keys() & allowed_config_kwargs } - new_cls = super().__new__(cls, name, bases, dict_used, **config_kwargs) + new_cls = cast( + "SQLModel", + super().__new__(cls, name, bases, dict_used, **config_kwargs) + ) new_cls.__annotations__ = { **relationship_annotations, **pydantic_annotations, @@ -610,7 +613,7 @@ def get_config(name: str) -> Any: new_cls.model_config["read_from_attributes"] = True # type: ignore[typeddict-unknown-key] # For compatibility with older versions # TODO: remove this in the future - new_cls.model_config["read_with_orm_mode"] = True + new_cls.model_config["read_with_orm_mode"] = True # type: ignore[typeddict-unknown-key] config_registry = get_config("registry") if config_registry is not Undefined: @@ -792,7 +795,7 @@ def get_column_from_field(field: Any) -> Column: # type: ignore ) if sa_column_kwargs is not Undefined: kwargs.update(cast(dict[Any, Any], sa_column_kwargs)) - return Column(sa_type, *args, **kwargs) # type: ignore + return Column(sa_type, *args, **kwargs) class_registry = weakref.WeakValueDictionary() # type: ignore From 08cc8676854d536408615e32dc2843010f34a668 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 3 Feb 2026 05:55:40 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqlmodel/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 5912572f4c..bdced7ddbe 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -580,8 +580,7 @@ def __new__( key: kwargs[key] for key in kwargs.keys() & allowed_config_kwargs } new_cls = cast( - "SQLModel", - super().__new__(cls, name, bases, dict_used, **config_kwargs) + "SQLModel", super().__new__(cls, name, bases, dict_used, **config_kwargs) ) new_cls.__annotations__ = { **relationship_annotations, From f7e8591b1e33ce1ea920c480de4c444f6019ffbf Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Tue, 3 Feb 2026 10:19:57 +0100 Subject: [PATCH 5/5] Remove `types: [python]` from mypy hook in `pre-commit.yaml` --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8558cc0fe3..8440301ad8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,6 @@ repos: require_serial: true language: unsupported pass_filenames: false - types: [python] - id: generate-select language: unsupported