mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 04:31:13 +00:00
[BugFix] openbb-core: Handle FastAPI 0.155.0 Query json_schema_extra default of None (#7803)
FastAPI 0.155.0 changed the default of Query(...).json_schema_extra from {}
to None. ReferenceGenerator._get_function_signature_info copied that value
and later called .pop() on it, which broke
test_get_function_signature_info_with_query_default and
test_get_function_signature_info_query_default_branch. CI installs the
newest FastAPI because it does not install from uv.lock. Fall back to {},
as the Annotated branch of the same function already does.
Also cover the unclosed-bracket fallbacks in docstring_generator
(_matching_bracket returning -1 and _rewrite_optional_and_union returning
the input unchanged), which no test reached since #7794.
Co-authored-by: dlee-bq <325002271+dlee-bq@users.noreply.github.com>
This commit is contained in:
@@ -602,7 +602,7 @@ class ReferenceGenerator:
|
||||
else str(param_type)
|
||||
)
|
||||
description = default.description # type: ignore
|
||||
json_extra = default.json_schema_extra # type: ignore
|
||||
json_extra = default.json_schema_extra or {} # type: ignore
|
||||
has_default = hasattr(default, "default") and default.default not in [
|
||||
Parameter.empty,
|
||||
PydanticUndefined,
|
||||
|
||||
@@ -1961,6 +1961,7 @@ def test_literal_choices_reads_bare_optional_and_non_literal_types():
|
||||
("list[typing.Optional[str]]", "list[str | None]"),
|
||||
("<class 'str'>", "str"),
|
||||
("datetime.date", "date"),
|
||||
("typing.Optional[str", "Optional[str"),
|
||||
# Literal still collapses to str; duplicates still collapse
|
||||
("typing.Optional[typing.Literal['a', 'b']]", "str | None"),
|
||||
("typing.Union[typing.Literal['a'], typing.Literal['b']]", "str"),
|
||||
|
||||
Reference in New Issue
Block a user