Browse Source

fix: Replace type ignore comments with explicit cast calls for mypy compatibility

pull/14142/head
I531058 10 months ago
parent
commit
182d727cc1
Failed to extract signature
  1. 6
      fastapi/_compat.py

6
fastapi/_compat.py

@ -486,9 +486,9 @@ else:
separate_input_output_schemas: bool = True, separate_input_output_schemas: bool = True,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
# This expects that GenerateJsonSchema was already used to generate the definitions # This expects that GenerateJsonSchema was already used to generate the definitions
json_schema = field_schema( # type: ignore[no-any-return] json_schema = cast(Dict[str, Any], field_schema(
field, model_name_map=model_name_map, ref_prefix=REF_PREFIX field, model_name_map=model_name_map, ref_prefix=REF_PREFIX
)[0] )[0])
# Check for PropertyNames constraint in field metadata # Check for PropertyNames constraint in field metadata
try: try:
@ -504,7 +504,7 @@ else:
def get_compat_model_name_map(fields: List[ModelField]) -> ModelNameMap: def get_compat_model_name_map(fields: List[ModelField]) -> ModelNameMap:
models = get_flat_models_from_fields(fields, known_models=set()) models = get_flat_models_from_fields(fields, known_models=set())
return get_model_name_map(models) # type: ignore[no-any-return] return cast(ModelNameMap, get_model_name_map(models))
def get_definitions( def get_definitions(
*, *,

Loading…
Cancel
Save