mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
fix prov interface typing
This commit is contained in:
@@ -290,7 +290,7 @@ class ProviderInterface:
|
||||
|
||||
@dataclass
|
||||
class StockNews(ProviderChoices):
|
||||
provider: Literal["benzinga", "polygon", "openbb"]
|
||||
provider: Literal["benzinga", "polygon"]
|
||||
"""
|
||||
|
||||
result: Dict = {}
|
||||
@@ -308,35 +308,6 @@ class ProviderInterface:
|
||||
|
||||
return result
|
||||
|
||||
def __merge_data_dc(self, data: Dict) -> Dict[str, StandardData]:
|
||||
result: Dict = {}
|
||||
for query_name, dataclasses in data.items():
|
||||
standard = dataclasses["standard"]
|
||||
extra = dataclasses["extra"]
|
||||
|
||||
fields = standard.__fields__.copy()
|
||||
fields.update(extra.__fields__)
|
||||
|
||||
fields_dict: Dict[str, Tuple[Any, Any]] = {}
|
||||
for name, field in fields.items():
|
||||
fields_dict[name] = (
|
||||
field.type_,
|
||||
Field(
|
||||
default=field.default, description=field.field_info.description
|
||||
),
|
||||
)
|
||||
|
||||
class Config(BaseConfig):
|
||||
extra = Extra.allow
|
||||
|
||||
result[query_name] = create_model( # type: ignore
|
||||
query_name,
|
||||
__config__=Config,
|
||||
**fields_dict, # type: ignore
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
def __generate_data_dc(
|
||||
self,
|
||||
) -> Dict[str, Dict[str, Union[StandardData, ExtraData]]]:
|
||||
@@ -374,6 +345,36 @@ class ProviderInterface:
|
||||
|
||||
return result
|
||||
|
||||
def __merge_data_dc(self, data: Dict[str, Dict[str, Union[StandardData, ExtraData]]]) -> Dict[str, BaseModel]:
|
||||
"""Merge standard data with extra data into a single BaseModel"""
|
||||
result: Dict = {}
|
||||
for query_name, dataclasses in data.items():
|
||||
standard = dataclasses["standard"]
|
||||
extra = dataclasses["extra"]
|
||||
|
||||
fields = standard.__fields__.copy()
|
||||
fields.update(extra.__fields__)
|
||||
|
||||
fields_dict: Dict[str, Tuple[Any, Any]] = {}
|
||||
for name, field in fields.items():
|
||||
fields_dict[name] = (
|
||||
field.type_,
|
||||
Field(
|
||||
default=field.default, description=field.field_info.description
|
||||
),
|
||||
)
|
||||
|
||||
class Config(BaseConfig):
|
||||
extra = Extra.allow
|
||||
|
||||
result[query_name] = create_model( # type: ignore
|
||||
query_name,
|
||||
__config__=Config,
|
||||
**fields_dict, # type: ignore
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
__provider_interface = ProviderInterface()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user