mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
MyPy
This commit is contained in:
@@ -48,4 +48,4 @@ try:
|
||||
sdk = obb
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
print("Failed to import extensions.")
|
||||
obb = sdk = _create_app()
|
||||
obb = sdk = _create_app() # type: ignore
|
||||
|
||||
@@ -4,12 +4,11 @@ import datetime
|
||||
from typing import List, Literal, Optional, Union
|
||||
|
||||
import pydantic
|
||||
import pydantic.main
|
||||
from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
|
||||
from openbb_core.app.model.obbject import OBBject
|
||||
from openbb_core.app.static.container import Container
|
||||
from openbb_core.app.static.filters import filter_inputs
|
||||
from pydantic import BaseModel, validate_arguments
|
||||
from pydantic import validate_arguments
|
||||
from typing_extensions import Annotated
|
||||
|
||||
|
||||
@@ -498,7 +497,7 @@ class CLASS_stocks(Container):
|
||||
chart: bool = False,
|
||||
provider: Optional[Literal["benzinga", "fmp", "polygon", "yfinance"]] = None,
|
||||
**kwargs
|
||||
) -> OBBject[BaseModel]:
|
||||
) -> OBBject[List]:
|
||||
"""Get news for one or more stock tickers.
|
||||
|
||||
Parameters
|
||||
|
||||
@@ -1294,7 +1294,7 @@ class CLASS_stocks_fa(Container):
|
||||
] = 12,
|
||||
provider: Optional[Literal["fmp", "polygon", "yfinance"]] = None,
|
||||
**kwargs
|
||||
) -> OBBject[BaseModel]:
|
||||
) -> OBBject[List]:
|
||||
"""Income Statement.
|
||||
|
||||
Parameters
|
||||
|
||||
@@ -8,7 +8,6 @@ from openbb_provider.standard_models.cot_search import (
|
||||
CotSearchData,
|
||||
CotSearchQueryParams,
|
||||
)
|
||||
|
||||
from openbb_quandl.utils.series_ids import CFTC
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class YFinanceIncomeStatementData(IncomeStatementData):
|
||||
class YFinanceIncomeStatementFetcher(
|
||||
Fetcher[
|
||||
YFinanceIncomeStatementQueryParams,
|
||||
YFinanceIncomeStatementData,
|
||||
List[YFinanceIncomeStatementData],
|
||||
]
|
||||
):
|
||||
@staticmethod
|
||||
@@ -47,7 +47,7 @@ class YFinanceIncomeStatementFetcher(
|
||||
credentials: Optional[Dict[str, str]],
|
||||
**kwargs: Any,
|
||||
) -> List[YFinanceIncomeStatementData]:
|
||||
query.period = "yearly" if query.period == "annually" else "quarterly"
|
||||
query.period = "yearly" if query.period == "annually" else "quarterly" # type: ignore
|
||||
data = Ticker(query.symbol).get_income_stmt(
|
||||
as_dict=True, pretty=False, freq=query.period
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ class YFinanceStockNewsData(StockNewsData):
|
||||
class YFinanceStockNewsFetcher(
|
||||
Fetcher[
|
||||
YFinanceStockNewsQueryParams,
|
||||
YFinanceStockNewsData,
|
||||
List[YFinanceStockNewsData],
|
||||
]
|
||||
):
|
||||
@staticmethod
|
||||
@@ -58,15 +58,15 @@ class YFinanceStockNewsFetcher(
|
||||
query: YFinanceStockNewsQueryParams,
|
||||
credentials: Optional[Dict[str, str]],
|
||||
**kwargs: Any,
|
||||
) -> List[YFinanceStockNewsData]:
|
||||
) -> dict:
|
||||
data = Ticker(query.symbols).get_news()
|
||||
data = json.loads(json.dumps(data))
|
||||
data = [{**d, "relatedTickers": ",".join(d["relatedTickers"])} for d in data]
|
||||
|
||||
return [YFinanceStockNewsData.parse_obj(d) for d in data]
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
data: List[YFinanceStockNewsData],
|
||||
data: dict,
|
||||
) -> List[YFinanceStockNewsData]:
|
||||
return data
|
||||
return [YFinanceStockNewsData.parse_obj(d) for d in data]
|
||||
|
||||
@@ -7,8 +7,6 @@ from sys import exc_info
|
||||
from time import perf_counter_ns
|
||||
from typing import Any, Callable, ContextManager, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from pydantic import BaseConfig, Extra, create_model
|
||||
|
||||
from openbb_core.app.charting_service import ChartingService
|
||||
from openbb_core.app.logs.logging_service import LoggingService
|
||||
from openbb_core.app.model.abstract.error import OpenBBError
|
||||
@@ -22,6 +20,7 @@ from openbb_core.app.router import CommandMap
|
||||
from openbb_core.app.service.system_service import SystemService
|
||||
from openbb_core.app.service.user_service import UserService
|
||||
from openbb_core.env import Env
|
||||
from pydantic import BaseConfig, Extra, create_model
|
||||
|
||||
|
||||
class ExecutionContext:
|
||||
|
||||
Reference in New Issue
Block a user