🚨 Fix mypy warnings about primary_key in fieldInfo
This commit is contained in:
parent
76d72cd32e
commit
79a2ba84e5
@ -240,7 +240,11 @@ if IS_PYDANTIC_V2:
|
|||||||
if name != "model_fields":
|
if name != "model_fields":
|
||||||
model_fields = object.__getattribute__(self, "model_fields")
|
model_fields = object.__getattribute__(self, "model_fields")
|
||||||
field = model_fields.get(name)
|
field = model_fields.get(name)
|
||||||
if field is not None and isinstance(field, FieldInfo):
|
if (
|
||||||
|
field is not None
|
||||||
|
and isinstance(field, FieldInfo)
|
||||||
|
and hasattr(field, "primary_key")
|
||||||
|
):
|
||||||
if field.primary_key and field.annotation is int and value is None:
|
if field.primary_key and field.annotation is int and value is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Primary key attribute '{name}' has not been set, please commit() it first."
|
f"Primary key attribute '{name}' has not been set, please commit() it first."
|
||||||
@ -547,7 +551,11 @@ else:
|
|||||||
if name != "__fields__":
|
if name != "__fields__":
|
||||||
fields = object.__getattribute__(self, "__fields__")
|
fields = object.__getattribute__(self, "__fields__")
|
||||||
field = fields.get(name)
|
field = fields.get(name)
|
||||||
if field is not None and isinstance(field.field_info, FieldInfo):
|
if (
|
||||||
|
field is not None
|
||||||
|
and isinstance(field.field_info, FieldInfo)
|
||||||
|
and hasattr(field.field_info, "primary_key")
|
||||||
|
):
|
||||||
if (
|
if (
|
||||||
field.field_info.primary_key
|
field.field_info.primary_key
|
||||||
and field.annotation is int
|
and field.annotation is int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user