]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
⬆ Bump mypy from 1.4.1 to 1.18.2 (#1560)
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Wed, 8 Oct 2025 11:10:30 +0000 (13:10 +0200)
committerGitHub <noreply@github.com>
Wed, 8 Oct 2025 11:10:30 +0000 (13:10 +0200)
* ⬆ 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] <support@github.com>
* 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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
pyproject.toml
requirements-tests.txt
sqlmodel/_compat.py
sqlmodel/main.py

index 4ae195ac7313022a310ebf711cf6349695e0fc2b..902fffdc9f5fa160cd2979b8cff21d40ae30d66c 100644 (file)
@@ -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.*"
index f6e826511d8ae04b93fe698157280a5b7666edef..6cae1015c9aaab4ee4d6423694e8d8e3818ff197 100644 (file)
@@ -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
index 38dd501c4a6c4a859f85641d20efb9ca5cb2ee80..dc806d381b713c5375db0ba17fb41fb947ff98b1 100644 (file)
@@ -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
 
index 1925a48f04174fabd6e7d055be437ec957dd455f..7c916f79af0deeb510ff2ac402253453b504c5ee 100644 (file)
@@ -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: