Skip to content

Commit f751e1c

Browse files
⬆ Bump mypy from 1.4.1 to 1.18.2 (#1560)
* ⬆ 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](python/mypy@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] <[email protected]> * 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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sofie Van Landeghem <[email protected]> Co-authored-by: svlandeg <[email protected]>
1 parent 2d3b25d commit f751e1c

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ show_contexts = true
9898

9999
[tool.mypy]
100100
strict = true
101-
102-
[[tool.mypy.overrides]]
103-
module = "sqlmodel.sql._expression_select_gen"
104-
warn_unused_ignores = false
101+
exclude = "sqlmodel.sql._expression_select_gen"
105102

106103
[[tool.mypy.overrides]]
107104
module = "docs_src.*"

requirements-tests.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
-r requirements-docs-tests.txt
33
pytest >=7.0.1,<9.0.0
44
coverage[toml] >=6.2,<8.0
5-
mypy ==1.4.1
5+
# Remove when support for Python 3.8 is dropped
6+
mypy ==1.14.1; python_version < "3.9"
7+
mypy ==1.18.2; python_version >= "3.9"
68
ruff ==0.13.2
79
# For FastAPI tests
810
fastapi >=0.103.2

sqlmodel/_compat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def init_pydantic_private_attrs(new_object: InstanceOrType["SQLModel"]) -> None:
123123
object.__setattr__(new_object, "__pydantic_private__", None)
124124

125125
def get_annotations(class_dict: Dict[str, Any]) -> Dict[str, Any]:
126-
return class_dict.get("__annotations__", {})
126+
return class_dict.get("__annotations__", {}) # type: ignore[no-any-return]
127127

128128
def is_table_model_class(cls: Type[Any]) -> bool:
129129
config = getattr(cls, "model_config", {})
@@ -180,7 +180,7 @@ def is_field_noneable(field: "FieldInfo") -> bool:
180180
if not field.is_required():
181181
if field.default is Undefined:
182182
return False
183-
if field.annotation is None or field.annotation is NoneType: # type: ignore[comparison-overlap]
183+
if field.annotation is None or field.annotation is NoneType:
184184
return True
185185
return False
186186
return False
@@ -509,7 +509,7 @@ def _calculate_keys(
509509
keys -= update.keys()
510510

511511
if exclude:
512-
keys -= {k for k, v in exclude.items() if ValueItems.is_true(v)}
512+
keys -= {str(k) for k, v in exclude.items() if ValueItems.is_true(v)}
513513

514514
return keys
515515

sqlmodel/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import ipaddress
24
import uuid
35
import weakref
@@ -601,7 +603,7 @@ def __init__(
601603
setattr(cls, rel_name, rel_info.sa_relationship) # Fix #315
602604
continue
603605
raw_ann = cls.__annotations__[rel_name]
604-
origin = get_origin(raw_ann)
606+
origin: Any = get_origin(raw_ann)
605607
if origin is Mapped:
606608
ann = raw_ann.__args__[0]
607609
else:

0 commit comments

Comments
 (0)