[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:
dlee-bq
2026-10-24 06:55:55 +00:00
committed by GitHub
parent 86e27341b0
commit 3b204c6964
2 changed files with 2 additions and 1 deletions

View File

@@ -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,

View File

@@ -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"),