mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-09 19:02:19 +00:00
[V5] CLI 2.0 - Pluggable Backends, Non-TTY Default, HTTP Dispatcher, Spec Files + Codegen (#7433)
* stash some changes * add more robust testing * mypy * point PR at V5 * introduce spec file * codespell * test fix * fix workflow environment setup * fix workflow environment setup * fix workflow environment setup * add pyyaml to dependencies * split lint jobs * fix workflow environment setup * fix workflow environment setup * workflow env setup * workflow env setup * clean up code comments * add auth hook entrypoints * codespell * add codegen feature * codespell * move _unpack into dispatchers for consistency with codegen packages * surface nested models in the response * fix missing coverage in CI * socrata updates * test fix * detect plotly output * add --include and --exclude flags from generate-extension command * cap test matrix at python 3.14 * no useless comments * platform controller command description split * merge URL overloads from path params * exclude none and unset from model dump --------- Co-authored-by: deeleeramone <> Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -27,26 +27,21 @@ class ReferenceToArgumentsProcessor:
|
||||
@staticmethod
|
||||
def _parse_type(type_string: str) -> type:
|
||||
"""Parse the type from the string representation."""
|
||||
# Handle Optional[T] or T | None
|
||||
if "Optional" in type_string or "|" in type_string:
|
||||
# Extract the inner type, defaulting to str if parsing fails
|
||||
match = re.search(r"Optional\[(\w+)]|(\w+)\s*\|\s*None", type_string)
|
||||
if match:
|
||||
type_string = next(
|
||||
(group for group in match.groups() if group is not None), "str"
|
||||
)
|
||||
|
||||
# Handle Literal types
|
||||
if "Literal" in type_string:
|
||||
return str # Treat all Literal types as strings for simplicity
|
||||
return str
|
||||
|
||||
# Handle Annotated types by extracting the base type
|
||||
if "Annotated" in type_string:
|
||||
match = re.search(r"Annotated\[(\w+),", type_string)
|
||||
if match:
|
||||
type_string = match.group(1)
|
||||
|
||||
# Map common string representations to actual types
|
||||
type_map = {
|
||||
"str": str,
|
||||
"int": int,
|
||||
@@ -69,14 +64,12 @@ class ReferenceToArgumentsProcessor:
|
||||
if custom_choices:
|
||||
return tuple(custom_choices)
|
||||
|
||||
# Find all occurrences of Literal[...]
|
||||
literal_matches = re.findall(r"Literal\[(.*?)\]", type_string)
|
||||
if not literal_matches:
|
||||
return None
|
||||
|
||||
all_choices: list = []
|
||||
for match in literal_matches:
|
||||
# Split by comma and strip quotes and whitespace
|
||||
choices = [c.strip().strip("'\"") for c in match.split(",") if c.strip()]
|
||||
all_choices.extend(choices)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user