Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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 @@ -600,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:
Expand Down
Loading