From f751e1c7976f08ed3674b890aa7e28a74d47c6e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 13:10:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=20Bump=20mypy=20from=201.4.1=20to=201?= =?UTF-8?q?.18.2=20(#1560)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ⬆ Bump mypy from 1.4.1 to 1.18.1 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] * restrict to latest version that supports python 3.8 * remove unnecssary ignore statement * add ignore statement * make ignore statement more specific * expand on mypy command to debug CI failure * experiment with from future import * use the latest mypy for Python 3.9 and up * fix type of keys to be removed * annotate origin as Any to avoid type issues * bump to 1.10.0 only for now * exclude one particular file from mypy processing * Try to bump to 1.18.2 again * attempt to remove the future import again * add back future import --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sofie Van Landeghem Co-authored-by: svlandeg --- pyproject.toml | 5 +---- requirements-tests.txt | 4 +++- sqlmodel/_compat.py | 6 +++--- sqlmodel/main.py | 4 +++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4ae195ac..902fffdc 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.*" diff --git a/requirements-tests.txt b/requirements-tests.txt index f6e82651..6cae1015 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.4.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 diff --git a/sqlmodel/_compat.py b/sqlmodel/_compat.py index 38dd501c..dc806d38 100644 --- a/sqlmodel/_compat.py +++ b/sqlmodel/_compat.py @@ -123,7 +123,7 @@ if IS_PYDANTIC_V2: 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[no-any-return] def is_table_model_class(cls: Type[Any]) -> bool: config = getattr(cls, "model_config", {}) @@ -180,7 +180,7 @@ if IS_PYDANTIC_V2: 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 @@ -509,7 +509,7 @@ else: 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 diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 1925a48f..7c916f79 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import ipaddress import uuid import weakref @@ -601,7 +603,7 @@ class SQLModelMetaclass(ModelMetaclass, DeclarativeMeta): 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: