Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
744954b
⬆ Bump mypy from 1.4.1 to 1.18.1
dependabot[bot] Sep 16, 2025
9110e0b
restrict to latest version that supports python 3.8
svlandeg Sep 16, 2025
35825de
Merge branch 'main' into dependabot/pip/mypy-1.18.1
svlandeg Sep 16, 2025
39f5bf5
remove unnecssary ignore statement
svlandeg Sep 16, 2025
479bbb6
add ignore statement
svlandeg Sep 16, 2025
a28075f
make ignore statement more specific
svlandeg Sep 16, 2025
a709b33
Merge branch 'main' into dependabot/pip/mypy-1.18.1
svlandeg Sep 16, 2025
74113b9
expand on mypy command to debug CI failure
svlandeg Sep 16, 2025
efe58df
Merge branch 'dependabot/pip/mypy-1.18.1' of https://github.com/fasta…
svlandeg Sep 16, 2025
94d0cb3
experiment with from future import
svlandeg Sep 16, 2025
94a7d1a
Merge branch 'main' into dependabot/pip/mypy-1.18.1
svlandeg Sep 26, 2025
8dca285
use the latest mypy for Python 3.9 and up
svlandeg Sep 26, 2025
5896004
fix type of keys to be removed
svlandeg Sep 26, 2025
b56fa37
annotate origin as Any to avoid type issues
svlandeg Sep 26, 2025
8cc9874
bump to 1.10.0 only for now
svlandeg Sep 29, 2025
763ef27
Merge branch 'main' into dependabot/pip/mypy-1.18.1
svlandeg Sep 29, 2025
9c4e0da
exclude one particular file from mypy processing
svlandeg Sep 29, 2025
4541f11
Try to bump to 1.18.2 again
svlandeg Sep 29, 2025
7446fb1
attempt to remove the future import again
svlandeg Sep 29, 2025
f30beb2
add back future import
svlandeg Sep 29, 2025
d787c3f
Merge branch 'main' into dependabot/pip/mypy-1.18.1
svlandeg Oct 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*"
Expand Down
4 changes: 3 additions & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sqlmodel/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[no-any-return]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As on L425, where we're already ignoring it, the error is

Returning Any from function declared to return "dict[str, Any]" [no-any-return]


def is_table_model_class(cls: Type[Any]) -> bool:
config = getattr(cls, "model_config", {})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion sqlmodel/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import ipaddress
import uuid
import weakref
Expand Down Expand Up @@ -601,7 +603,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:
Expand Down
Loading