mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-09 10:51:57 +00:00
Fix more mypy warnings
This commit is contained in:
@@ -29,6 +29,7 @@ class OpenBBFigureTable(OpenBBFigure):
|
||||
if not self._backend.isatty:
|
||||
tmp_fig = self.to_table()
|
||||
tmp_fig.show()
|
||||
return None
|
||||
else:
|
||||
# Make a copy of the dataframe to avoid SettingWithCopyWarning
|
||||
df = self._tabular_data.copy()
|
||||
@@ -81,6 +82,8 @@ class OpenBBFigureTable(OpenBBFigure):
|
||||
theme=self._charting_settings.table_style,
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
def to_table(
|
||||
self,
|
||||
print_index: bool = True,
|
||||
|
||||
@@ -101,7 +101,7 @@ class CboeStockInfoFetcher(
|
||||
return get_info(query.symbol).to_dict()
|
||||
|
||||
@staticmethod
|
||||
def transform_data(data: dict) -> CboeStockInfoData:
|
||||
def transform_data(data: dict) -> List[CboeStockInfoData]:
|
||||
"""Transform the data to the standard format"""
|
||||
|
||||
return CboeStockInfoData.parse_obj(data)
|
||||
return [CboeStockInfoData.parse_obj(data)]
|
||||
|
||||
@@ -111,7 +111,9 @@ class FMPFinancialRatiosFetcher(
|
||||
|
||||
api_key = credentials.get("fmp_api_key") if credentials else ""
|
||||
|
||||
query.period = "annual" if query.period == "annually" else "quarter"
|
||||
query.period = (
|
||||
"annual" if query.period == "annually" else "quarter" # mypy: ignore
|
||||
)
|
||||
base_url = "https://financialmodelingprep.com/api/v3"
|
||||
|
||||
data: List[Dict] = []
|
||||
|
||||
@@ -58,7 +58,6 @@ class FMPStockPeersFetcher(
|
||||
return get_data_one(url, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def transform_data(data: Dict) -> StockPeersData:
|
||||
def transform_data(data: Dict) -> FMPStockPeersData:
|
||||
"""Return the transformed data."""
|
||||
|
||||
return StockPeersData(**data)
|
||||
return FMPStockPeersData(**data)
|
||||
|
||||
@@ -80,7 +80,6 @@ class FMPStockQuoteFetcher(
|
||||
return get_data_many(url, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def transform_data(data: List[Dict]) -> List[StockQuoteData]:
|
||||
def transform_data(data: List[Dict]) -> List[FMPStockQuoteData]:
|
||||
"""Return the transformed data."""
|
||||
|
||||
return [StockQuoteData(**d) for d in data]
|
||||
return [FMPStockQuoteData(**d) for d in data]
|
||||
|
||||
@@ -61,7 +61,7 @@ class PolygonCashFlowStatementFetcher(
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
data: dict,
|
||||
) -> List[CashFlowStatementData]:
|
||||
) -> List[PolygonCashFlowStatementData]:
|
||||
FIELDS = [
|
||||
"net_cash_flow_from_financing_activities",
|
||||
"net_cash_flow_from_investing_activities",
|
||||
|
||||
@@ -106,5 +106,5 @@ class PolygonCryptoEODFetcher(
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
def transform_data(data: dict) -> List[CryptoEODData]:
|
||||
def transform_data(data: dict) -> List[PolygonCryptoEODData]:
|
||||
return [PolygonCryptoEODData.parse_obj(d) for d in data.get("results", [])]
|
||||
|
||||
@@ -34,9 +34,9 @@ class PolygonIncomeStatementData(IncomeStatementData):
|
||||
# tickers: Optional[List[str]]
|
||||
cik: Optional[str]
|
||||
filing_date: Optional[dateType]
|
||||
cost_of_revenue: Optional[float]
|
||||
gross_profit: Optional[float]
|
||||
operating_expenses: Optional[float]
|
||||
cost_of_revenue: Optional[int]
|
||||
gross_profit: Optional[int]
|
||||
operating_expenses: Optional[int]
|
||||
income_loss_from_continuing_operations_after_tax: Optional[float]
|
||||
benefits_costs_expenses: Optional[float]
|
||||
net_income_loss_attributable_to_noncontrolling_interest: Optional[int]
|
||||
@@ -87,7 +87,7 @@ class PolygonIncomeStatementFetcher(
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
data: dict,
|
||||
) -> List[IncomeStatementData]:
|
||||
) -> List[PolygonIncomeStatementData]:
|
||||
FIELDS = [
|
||||
"revenues",
|
||||
"cost_of_revenue",
|
||||
|
||||
@@ -104,7 +104,7 @@ class PolygonMajorIndicesEODFetcher(
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
data: dict,
|
||||
) -> List[MajorIndicesEODData]:
|
||||
) -> List[PolygonMajorIndicesEODData]:
|
||||
return [
|
||||
PolygonMajorIndicesEODData.parse_obj(d) for d in data.get("results", [])
|
||||
]
|
||||
|
||||
@@ -115,5 +115,5 @@ class PolygonStockNewsFetcher(
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
data: dict,
|
||||
) -> List[StockNewsData]:
|
||||
) -> List[PolygonStockNewsData]:
|
||||
return [PolygonStockNewsData(**d) for d in data]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# IMPORT STANDARD
|
||||
import time
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PosixPath
|
||||
|
||||
# IMPORT THIRD-PARTY
|
||||
# IMPORT INTERNAL
|
||||
@@ -31,7 +31,7 @@ def get_app_id(contextual_user_data_directory: str) -> str:
|
||||
return app_id
|
||||
|
||||
|
||||
def get_log_dir(contextual_user_data_directory: str) -> str:
|
||||
def get_log_dir(contextual_user_data_directory: str) -> PosixPath:
|
||||
"""Retrieve application's log directory."""
|
||||
|
||||
log_dir = create_log_dir_if_not_exists(contextual_user_data_directory)
|
||||
@@ -64,7 +64,7 @@ def get_log_id(log_dir):
|
||||
return (log_dir / ".logid").absolute()
|
||||
|
||||
|
||||
def create_uuid_dir_if_not_exists(log_dir, logging_id) -> str:
|
||||
def create_uuid_dir_if_not_exists(log_dir, logging_id) -> PosixPath:
|
||||
uuid_log_dir = (log_dir / logging_id).absolute()
|
||||
|
||||
if not uuid_log_dir.is_dir():
|
||||
|
||||
@@ -389,9 +389,9 @@ class CommandMap:
|
||||
coverage_map[provider] = []
|
||||
if hasattr(route, "path"):
|
||||
rp = (
|
||||
route.path
|
||||
route.path # type: ignore
|
||||
if sep is None
|
||||
else route.path.replace("/", sep)
|
||||
else route.path.replace("/", sep) # type: ignore
|
||||
)
|
||||
coverage_map[provider].append(rp)
|
||||
|
||||
@@ -416,8 +416,10 @@ class CommandMap:
|
||||
providers.remove("openbb")
|
||||
|
||||
if hasattr(route, "path"):
|
||||
rp = route.path if sep is None else route.path.replace("/", sep)
|
||||
if route.path not in coverage_map:
|
||||
rp = (
|
||||
route.path if sep is None else route.path.replace("/", sep) # type: ignore
|
||||
)
|
||||
if route.path not in coverage_map: # type: ignore
|
||||
coverage_map[rp] = []
|
||||
coverage_map[rp] = providers
|
||||
return coverage_map
|
||||
|
||||
@@ -21,9 +21,7 @@ class StockQuoteQueryParams(QueryParams, BaseSymbol):
|
||||
Comma separated list of symbols.
|
||||
"""
|
||||
|
||||
symbol: Optional[str] = Field(
|
||||
default=None, description="Comma separated list of symbols."
|
||||
)
|
||||
symbol: str = Field(default=None, description="Comma separated list of symbols.")
|
||||
|
||||
|
||||
class StockQuoteData(Data):
|
||||
|
||||
Reference in New Issue
Block a user