mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-29 17:42:12 +08:00
Update `get_definitions()` to FastAPI 0.128.8
This commit is contained in:
@@ -8,7 +8,6 @@ from typing import (
|
||||
|
||||
from fastapi._compat.v2 import (
|
||||
_has_computed_fields,
|
||||
_remap_definitions_and_field_mappings,
|
||||
get_flat_models_from_fields,
|
||||
ModelField,
|
||||
)
|
||||
@@ -53,8 +52,8 @@ def get_definitions(
|
||||
for model in flat_serialization_models
|
||||
]
|
||||
flat_model_fields = flat_validation_model_fields + flat_serialization_model_fields
|
||||
input_types = {f.type_ for f in fields}
|
||||
unique_flat_model_fields = {f for f in flat_model_fields if f.type_ not in input_types}
|
||||
input_types = {f.field_info.annotation for f in fields}
|
||||
unique_flat_model_fields = {f for f in flat_model_fields if f.field_info.annotation not in input_types}
|
||||
inputs = [
|
||||
(
|
||||
field,
|
||||
@@ -68,9 +67,9 @@ def get_definitions(
|
||||
if "description" in item_def:
|
||||
item_description = cast(str, item_def["description"]).split("\f")[0]
|
||||
item_def["description"] = item_description
|
||||
new_mapping, new_definitions = _remap_definitions_and_field_mappings(
|
||||
model_name_map=model_name_map,
|
||||
definitions=definitions, # type: ignore[arg-type]
|
||||
field_mapping=field_mapping,
|
||||
)
|
||||
return new_mapping, new_definitions
|
||||
# definitions: dict[DefsRef, dict[str, Any]]
|
||||
# but mypy complains about general str in other places that are not declared as
|
||||
# DefsRef, although DefsRef is just str:
|
||||
# DefsRef = NewType('DefsRef', str)
|
||||
# So, a cast to simplify the types here
|
||||
return field_mapping, cast(dict[str, dict[str, Any]], definitions)
|
||||
|
||||
Reference in New Issue
Block a user