Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ repos:
language: unsupported
types: [python]

- id: local-mypy
name: mypy check
entry: uv run mypy sqlmodel tests/test_select_typing.py
require_serial: true
language: unsupported
pass_filenames: false

- id: generate-select
language: unsupported
name: generate-select
Expand Down
10 changes: 6 additions & 4 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ def __new__(
config_kwargs = {
key: kwargs[key] for key in kwargs.keys() & allowed_config_kwargs
}
new_cls = super().__new__(cls, name, bases, dict_used, **config_kwargs)
new_cls = cast(
"SQLModel", super().__new__(cls, name, bases, dict_used, **config_kwargs)
)
new_cls.__annotations__ = {
**relationship_annotations,
**pydantic_annotations,
Expand Down Expand Up @@ -607,10 +609,10 @@ def get_config(name: str) -> Any:
# This could be done by reading new_cls.model_config['table'] in FastAPI, but
# that's very specific about SQLModel, so let's have another config that
# other future tools based on Pydantic can use.
new_cls.model_config["read_from_attributes"] = True
new_cls.model_config["read_from_attributes"] = True # type: ignore[typeddict-unknown-key]
# For compatibility with older versions
# TODO: remove this in the future
new_cls.model_config["read_with_orm_mode"] = True
new_cls.model_config["read_with_orm_mode"] = True # type: ignore[typeddict-unknown-key]

config_registry = get_config("registry")
if config_registry is not Undefined:
Expand Down Expand Up @@ -792,7 +794,7 @@ def get_column_from_field(field: Any) -> Column: # type: ignore
)
if sa_column_kwargs is not Undefined:
kwargs.update(cast(dict[Any, Any], sa_column_kwargs))
return Column(sa_type, *args, **kwargs) # type: ignore
return Column(sa_type, *args, **kwargs)


class_registry = weakref.WeakValueDictionary() # type: ignore
Expand Down