From 744954bbae8226dd8d6c03f904ac2c61b2a78b9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 08:57:06 +0000 Subject: [PATCH 01/15] =?UTF-8?q?=E2=AC=86=20Bump=20mypy=20from=201.4.1=20?= =?UTF-8?q?to=201.18.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [mypy](https://github.com/python/mypy) from 1.4.1 to 1.18.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.4.1...v1.18.1) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.18.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index dc738ea93b..99dcfe59f4 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,7 +2,7 @@ -r requirements-docs-tests.txt pytest >=7.0.1,<9.0.0 coverage[toml] >=6.2,<8.0 -mypy ==1.4.1 +mypy ==1.18.1 ruff ==0.13.0 # For FastAPI tests fastapi >=0.103.2 From 9110e0b936f1a5a4268a0931a4dc95d34f09fe6c Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Tue, 16 Sep 2025 15:08:49 +0200 Subject: [PATCH 02/15] restrict to latest version that supports python 3.8 --- requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 99dcfe59f4..875a1cc94a 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,7 +2,7 @@ -r requirements-docs-tests.txt pytest >=7.0.1,<9.0.0 coverage[toml] >=6.2,<8.0 -mypy ==1.18.1 +mypy ==1.14.1 ruff ==0.13.0 # For FastAPI tests fastapi >=0.103.2 From 39f5bf5962175a94a3716f690827001b7b59750c Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 16 Sep 2025 15:38:21 +0200 Subject: [PATCH 03/15] remove unnecssary ignore statement --- sqlmodel/_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/_compat.py b/sqlmodel/_compat.py index 38dd501c4a..7b80600c24 100644 --- a/sqlmodel/_compat.py +++ b/sqlmodel/_compat.py @@ -180,7 +180,7 @@ def is_field_noneable(field: "FieldInfo") -> bool: if not field.is_required(): if field.default is Undefined: return False - if field.annotation is None or field.annotation is NoneType: # type: ignore[comparison-overlap] + if field.annotation is None or field.annotation is NoneType: return True return False return False From 479bbb69d804a45ccf5a73de8b29b47c150937f2 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 16 Sep 2025 15:38:30 +0200 Subject: [PATCH 04/15] add ignore statement --- sqlmodel/_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/_compat.py b/sqlmodel/_compat.py index 7b80600c24..5a127a0627 100644 --- a/sqlmodel/_compat.py +++ b/sqlmodel/_compat.py @@ -123,7 +123,7 @@ def init_pydantic_private_attrs(new_object: InstanceOrType["SQLModel"]) -> None: object.__setattr__(new_object, "__pydantic_private__", None) def get_annotations(class_dict: Dict[str, Any]) -> Dict[str, Any]: - return class_dict.get("__annotations__", {}) + return class_dict.get("__annotations__", {}) # type: ignore def is_table_model_class(cls: Type[Any]) -> bool: config = getattr(cls, "model_config", {}) From a28075f5e886e5dc2801171eec2c5e5bef6dc5a6 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 16 Sep 2025 15:40:25 +0200 Subject: [PATCH 05/15] make ignore statement more specific --- sqlmodel/_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/_compat.py b/sqlmodel/_compat.py index 5a127a0627..4132861975 100644 --- a/sqlmodel/_compat.py +++ b/sqlmodel/_compat.py @@ -123,7 +123,7 @@ def init_pydantic_private_attrs(new_object: InstanceOrType["SQLModel"]) -> None: object.__setattr__(new_object, "__pydantic_private__", None) def get_annotations(class_dict: Dict[str, Any]) -> Dict[str, Any]: - return class_dict.get("__annotations__", {}) # type: ignore + return class_dict.get("__annotations__", {}) # type: ignore[no-any-return] def is_table_model_class(cls: Type[Any]) -> bool: config = getattr(cls, "model_config", {}) From 74113b9a160979bd57e4a94f277a160068b1e807 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 16 Sep 2025 19:15:17 +0200 Subject: [PATCH 06/15] expand on mypy command to debug CI failure --- scripts/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 7fab52df57..0e7a1d2e6c 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -3,6 +3,6 @@ set -e set -x -mypy sqlmodel +mypy --no-incremental --show-absolute-path ./sqlmodel ruff check sqlmodel tests docs_src scripts ruff format sqlmodel tests docs_src scripts --check From 94d0cb308454811360ebf8caaa128e4755168539 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Tue, 16 Sep 2025 20:51:12 +0200 Subject: [PATCH 07/15] experiment with from future import --- scripts/lint.sh | 2 +- sqlmodel/main.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 0e7a1d2e6c..7fab52df57 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -3,6 +3,6 @@ set -e set -x -mypy --no-incremental --show-absolute-path ./sqlmodel +mypy sqlmodel ruff check sqlmodel tests docs_src scripts ruff format sqlmodel tests docs_src scripts --check diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 38c85915aa..366c906295 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ipaddress import uuid import weakref From 8dca285b626b78b9a9946ede2a947056d85a4d92 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 26 Sep 2025 16:05:28 +0200 Subject: [PATCH 08/15] use the latest mypy for Python 3.9 and up --- requirements-tests.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index e9bb3357b9..6cae1015c9 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,7 +2,9 @@ -r requirements-docs-tests.txt pytest >=7.0.1,<9.0.0 coverage[toml] >=6.2,<8.0 -mypy ==1.14.1 +# Remove when support for Python 3.8 is dropped +mypy ==1.14.1; python_version < "3.9" +mypy ==1.18.2; python_version >= "3.9" ruff ==0.13.2 # For FastAPI tests fastapi >=0.103.2 From 5896004fcfb5729b1411fd298adfe7e86f897148 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 26 Sep 2025 16:33:42 +0200 Subject: [PATCH 09/15] fix type of keys to be removed --- sqlmodel/_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/_compat.py b/sqlmodel/_compat.py index 4132861975..dc806d381b 100644 --- a/sqlmodel/_compat.py +++ b/sqlmodel/_compat.py @@ -509,7 +509,7 @@ def _calculate_keys( keys -= update.keys() if exclude: - keys -= {k for k, v in exclude.items() if ValueItems.is_true(v)} + keys -= {str(k) for k, v in exclude.items() if ValueItems.is_true(v)} return keys From b56fa376a1c89aa69f153aef4b402881107dbf16 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 26 Sep 2025 16:42:18 +0200 Subject: [PATCH 10/15] annotate origin as Any to avoid type issues --- sqlmodel/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 366c906295..f4ee067ec4 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -602,7 +602,7 @@ def __init__( setattr(cls, rel_name, rel_info.sa_relationship) # Fix #315 continue raw_ann = cls.__annotations__[rel_name] - origin = get_origin(raw_ann) + origin: Any = get_origin(raw_ann) if origin is Mapped: ann = raw_ann.__args__[0] else: From 8cc9874b98ab03e03a8b0e1e13bbad17199fbc96 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 29 Sep 2025 14:40:32 +0200 Subject: [PATCH 11/15] bump to 1.10.0 only for now --- requirements-tests.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 6cae1015c9..6cb3cbf168 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,9 +2,7 @@ -r requirements-docs-tests.txt pytest >=7.0.1,<9.0.0 coverage[toml] >=6.2,<8.0 -# Remove when support for Python 3.8 is dropped -mypy ==1.14.1; python_version < "3.9" -mypy ==1.18.2; python_version >= "3.9" +mypy ==1.10.0 ruff ==0.13.2 # For FastAPI tests fastapi >=0.103.2 From 9c4e0da94d63f53696829a7951cfee5a74549895 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 29 Sep 2025 16:22:19 +0200 Subject: [PATCH 12/15] exclude one particular file from mypy processing --- pyproject.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4ae195ac73..902fffdc9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,10 +98,7 @@ show_contexts = true [tool.mypy] strict = true - -[[tool.mypy.overrides]] -module = "sqlmodel.sql._expression_select_gen" -warn_unused_ignores = false +exclude = "sqlmodel.sql._expression_select_gen" [[tool.mypy.overrides]] module = "docs_src.*" From 4541f11ef4d7b3287da3478ccd6bb2e010fedf64 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 29 Sep 2025 16:28:14 +0200 Subject: [PATCH 13/15] Try to bump to 1.18.2 again --- requirements-tests.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 6cb3cbf168..6cae1015c9 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -2,7 +2,9 @@ -r requirements-docs-tests.txt pytest >=7.0.1,<9.0.0 coverage[toml] >=6.2,<8.0 -mypy ==1.10.0 +# Remove when support for Python 3.8 is dropped +mypy ==1.14.1; python_version < "3.9" +mypy ==1.18.2; python_version >= "3.9" ruff ==0.13.2 # For FastAPI tests fastapi >=0.103.2 From 7446fb1ac6ec01c0984d68644d24a468e7a3b5d6 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 29 Sep 2025 16:44:15 +0200 Subject: [PATCH 14/15] attempt to remove the future import again --- sqlmodel/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index f4ee067ec4..3f3816636b 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import ipaddress import uuid import weakref From f30beb2397e3c52411ded4b0ee19a315fa5a78b7 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Mon, 29 Sep 2025 16:55:11 +0200 Subject: [PATCH 15/15] add back future import --- sqlmodel/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 3f3816636b..f4ee067ec4 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ipaddress import uuid import weakref