fix bug with generic

This commit is contained in:
Diogo Sousa
2023-07-31 11:40:36 +01:00
parent a79ae394c1
commit d9b7cef58e
2 changed files with 7 additions and 3 deletions

View File

@@ -416,7 +416,7 @@ class ProviderInterface:
types_list.append(ret)
if types_list:
returns[model_name] = Union[*types_list] # type: ignore
returns[model_name] = Union[tuple(types_list)] # type: ignore
return returns
@@ -455,7 +455,8 @@ class ProviderInterface:
)
ReturnType = merged_return_type.get(model_name, GenericDataType)
result[model_name] = ReturnType[ReturnModel] # type: ignore
n_params = len(getattr(ReturnType, "__parameters__", ()))
result[model_name] = ReturnType[tuple([ReturnModel] * n_params)] # type: ignore
return result

View File

@@ -1,6 +1,7 @@
"""Abstract class for the fetcher."""
from abc import abstractmethod
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
from openbb_provider.abstract.data import Data
@@ -77,6 +78,8 @@ class Fetcher(
# pylint: disable=E1101
return self.__orig_bases__[0].__args__[3]
# TODO: Create abstract class attribute for generic return type
# @property
# @abstractmethod
# def generic_return_type(self):
# """Get the type of the generic return."""
# raise NotImplementedError