language: unsupported
types: [python]
+ - id: local-mypy
+ name: mypy check
+ entry: uv run mypy fastapi
+ require_serial: true
+ language: unsupported
+ pass_filenames: false
+
- id: add-permalinks-pages
language: unsupported
name: add-permalinks-pages
@lru_cache
def get_cached_model_fields(model: type[BaseModel]) -> list[ModelField]:
- return get_model_fields(model) # type: ignore[return-value]
+ return get_model_fields(model)
# Duplicate of several schema functions from Pydantic v1 to make them compatible with
def get_compat_model_name_map(fields: list[ModelField]) -> ModelNameMap:
- all_flat_models = set()
+ all_flat_models: TypeModelSet = set()
v2_model_fields = [field for field in fields if isinstance(field, ModelField)]
v2_flat_models = get_flat_models_from_fields(v2_model_fields, known_models=set())
- all_flat_models = all_flat_models.union(v2_flat_models) # type: ignore[arg-type]
+ all_flat_models = all_flat_models.union(v2_flat_models)
- model_name_map = get_model_name_map(all_flat_models) # type: ignore[arg-type]
+ model_name_map = get_model_name_map(all_flat_models)
return model_name_map
if isinstance(fastapi_annotation, FieldInfo):
# Copy `field_info` because we mutate `field_info.default` below.
field_info = copy_field_info(
- field_info=fastapi_annotation, # type: ignore[arg-type]
+ field_info=fastapi_annotation,
annotation=use_annotation,
)
assert (
"Cannot specify FastAPI annotations in `Annotated` and default value"
f" together for {param_name!r}"
)
- field_info = value # type: ignore[assignment]
+ field_info = value
if isinstance(field_info, FieldInfo):
field_info.annotation = type_annotation
field_info = field_info or FieldInfo(annotation=type_, default=default, alias=alias)
kwargs = {"mode": mode, "name": name, "field_info": field_info}
try:
- return v2.ModelField(**kwargs) # type: ignore[return-value,arg-type]
+ return v2.ModelField(**kwargs) # type: ignore[arg-type]
except PydanticSchemaGenerationError:
raise fastapi.exceptions.FastAPIError(
_invalid_args_message.format(type_=type_)