mirror of
https://github.com/fastapi/sqlmodel.git
synced 2025-10-27 19:47:12 +08:00
⬆ 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](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>
This commit is contained in:
@ -98,10 +98,7 @@ show_contexts = true
|
|||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
strict = true
|
strict = true
|
||||||
|
exclude = "sqlmodel.sql._expression_select_gen"
|
||||||
[[tool.mypy.overrides]]
|
|
||||||
module = "sqlmodel.sql._expression_select_gen"
|
|
||||||
warn_unused_ignores = false
|
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
module = "docs_src.*"
|
module = "docs_src.*"
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
-r requirements-docs-tests.txt
|
-r requirements-docs-tests.txt
|
||||||
pytest >=7.0.1,<9.0.0
|
pytest >=7.0.1,<9.0.0
|
||||||
coverage[toml] >=6.2,<8.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
|
ruff ==0.13.2
|
||||||
# For FastAPI tests
|
# For FastAPI tests
|
||||||
fastapi >=0.103.2
|
fastapi >=0.103.2
|
||||||
|
|||||||
@ -123,7 +123,7 @@ if IS_PYDANTIC_V2:
|
|||||||
object.__setattr__(new_object, "__pydantic_private__", None)
|
object.__setattr__(new_object, "__pydantic_private__", None)
|
||||||
|
|
||||||
def get_annotations(class_dict: Dict[str, Any]) -> Dict[str, Any]:
|
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:
|
def is_table_model_class(cls: Type[Any]) -> bool:
|
||||||
config = getattr(cls, "model_config", {})
|
config = getattr(cls, "model_config", {})
|
||||||
@ -180,7 +180,7 @@ if IS_PYDANTIC_V2:
|
|||||||
if not field.is_required():
|
if not field.is_required():
|
||||||
if field.default is Undefined:
|
if field.default is Undefined:
|
||||||
return False
|
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 True
|
||||||
return False
|
return False
|
||||||
return False
|
return False
|
||||||
@ -509,7 +509,7 @@ else:
|
|||||||
keys -= update.keys()
|
keys -= update.keys()
|
||||||
|
|
||||||
if exclude:
|
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
|
return keys
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import uuid
|
import uuid
|
||||||
import weakref
|
import weakref
|
||||||
@ -601,7 +603,7 @@ class SQLModelMetaclass(ModelMetaclass, DeclarativeMeta):
|
|||||||
setattr(cls, rel_name, rel_info.sa_relationship) # Fix #315
|
setattr(cls, rel_name, rel_info.sa_relationship) # Fix #315
|
||||||
continue
|
continue
|
||||||
raw_ann = cls.__annotations__[rel_name]
|
raw_ann = cls.__annotations__[rel_name]
|
||||||
origin = get_origin(raw_ann)
|
origin: Any = get_origin(raw_ann)
|
||||||
if origin is Mapped:
|
if origin is Mapped:
|
||||||
ann = raw_ann.__args__[0]
|
ann = raw_ann.__args__[0]
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user