summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrique Joaquim <henriquecjoaquim@gmail.com>2024-05-07 11:57:03 +0100
committerGitHub <noreply@github.com>2024-05-07 10:57:03 +0000
commit63723f7b2cb01e91a6dace483ac8071772944110 (patch)
tree1236429e5fc680b00859ea2333ccdbae378c41d0
parent380891de4e23cf4bfdc9cbd0904195ad315eaf75 (diff)
[BugFix] Remove `Literal[None,...]` (#6371)
* remove Literal[None,...] * pylint: disable=unused-argument * change to Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 3257224 3044 3254180 1% /run /dev/nvme0n1p5 491732848 290872352 175808336 63% / tmpfs 16286112 81500 16204612 1% /dev/shm tmpfs 5120 8 5112 1% /run/lock efivarfs 246 66 176 28% /sys/firmware/efi/efivars tmpfs 16286112 0 16286112 0% /run/qemu /dev/nvme0n1p1 262144 60008 202136 23% /boot/efi tmpfs 3257220 15056 3242164 1% /run/user/1000 to avoid misleading linting attr errors
-rw-r--r--openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py24
-rw-r--r--openbb_platform/providers/fred/openbb_fred/models/search.py4
-rw-r--r--openbb_platform/providers/fred/openbb_fred/models/series.py45
-rw-r--r--openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py2
-rw-r--r--openbb_platform/providers/polygon/openbb_polygon/models/cash_flow.py8
-rw-r--r--openbb_platform/providers/tmx/openbb_tmx/models/index_snapshots.py2
6 files changed, 44 insertions, 41 deletions
diff --git a/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py b/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py
index cd0c703ea62..77313159449 100644
--- a/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py
+++ b/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py
@@ -21,7 +21,7 @@ class CboeIndexSnapshotsQueryParams(IndexSnapshotsQueryParams):
Source: https://www.cboe.com/
"""
- region: Literal[None, "us", "eu"] = Field(
+ region: Optional[Literal["us", "eu"]] = Field(
default="us",
)
@@ -89,7 +89,7 @@ class CboeIndexSnapshotsFetcher(
@staticmethod
async def aextract_data(
query: CboeIndexSnapshotsQueryParams,
- credentials: Optional[Dict[str, str]],
+ credentials: Optional[Dict[str, str]], # pylint: disable=unused-argument
**kwargs: Any,
) -> List[Dict]:
"""Return the raw data from the Cboe endpoint"""
@@ -104,12 +104,14 @@ class CboeIndexSnapshotsFetcher(
@staticmethod
def transform_data(
- query: CboeIndexSnapshotsQueryParams, data: dict, **kwargs: Any
+ query: CboeIndexSnapshotsQueryParams, # pylint: disable=unused-argument
+ data: dict,
+ **kwargs: Any, # pylint: disable=unused-argument
) -> List[CboeIndexSnapshotsData]:
"""Transform the data to the standard format"""
if not data:
raise EmptyDataError()
- data = DataFrame(data)
+ df = DataFrame(data)
percent_cols = [
"price_change_percent",
"iv30",
@@ -117,10 +119,10 @@ class CboeIndexSnapshotsFetcher(
"iv30_change_percent",
]
for col in percent_cols:
- if col in data.columns:
- data[col] = round(data[col] / 100, 6)
- data = (
- data.replace(0, None)
+ if col in df.columns:
+ df[col] = round(df[col] / 100, 6)
+ df = (
+ df.replace(0, None)
.replace("", None)
.dropna(how="all", axis=1)
.fillna("N/A")
@@ -135,9 +137,9 @@ class CboeIndexSnapshotsFetcher(
"bid_size",
]
for col in drop_cols:
- if col in data.columns:
- data = data.drop(columns=col)
+ if col in df.columns:
+ df = df.drop(columns=col)
return [
CboeIndexSnapshotsData.model_validate(d)
- for d in data.to_dict(orient="records")
+ for d in df.to_dict(orient="records")
]
diff --git a/openbb_platform/providers/fred/openbb_fred/models/search.py b/openbb_platform/providers/fred/openbb_fred/models/search.py
index 99bf76c7183..0681472256a 100644
--- a/openbb_platform/providers/fred/openbb_fred/models/search.py
+++ b/openbb_platform/providers/fred/openbb_fred/models/search.py
@@ -41,8 +41,8 @@ class FredSearchQueryParams(SearchQueryParams):
default=0,
description="Offset the results in conjunction with limit.",
)
- filter_variable: Literal[None, "frequency", "units", "seasonal_adjustment"] = Field(
- default=None, description="Filter by an attribute."
+ filter_variable: Optional[Literal["frequency", "units", "seasonal_adjustment"]] = (
+ Field(default=None, description="Filter by an attribute.")
)
filter_value: Optional[str] = Field(
default=None,
diff --git a/openbb_platform/providers/fred/openbb_fred/models/series.py b/openbb_platform/providers/fred/openbb_fred/models/series.py
index 7c1108e73f3..36e5f911c57 100644
--- a/openbb_platform/providers/fred/openbb_fred/models/series.py
+++ b/openbb_platform/providers/fred/openbb_fred/models/series.py
@@ -30,22 +30,23 @@ class FredSeriesQueryParams(SeriesQueryParams):
}
__json_schema_extra__ = {"symbol": ["multiple_items_allowed"]}
- frequency: Literal[
- None,
- "a",
- "q",
- "m",
- "w",
- "d",
- "wef",
- "weth",
- "wew",
- "wetu",
- "wem",
- "wesu",
- "wesa",
- "bwew",
- "bwem",
+ frequency: Optional[
+ Literal[
+ "a",
+ "q",
+ "m",
+ "w",
+ "d",
+ "wef",
+ "weth",
+ "wew",
+ "wetu",
+ "wem",
+ "wesu",
+ "wesa",
+ "bwew",
+ "bwem",
+ ]
] = Field(
default=None,
description="""
@@ -67,7 +68,7 @@ class FredSeriesQueryParams(SeriesQueryParams):
bwem = Biweekly, Ending Monday
""",
)
- aggregation_method: Literal[None, "avg", "sum", "eop"] = Field(
+ aggregation_method: Optional[Literal["avg", "sum", "eop"]] = Field(
default="eop",
description="""
A key that indicates the aggregation method used for frequency aggregation.
@@ -77,10 +78,11 @@ class FredSeriesQueryParams(SeriesQueryParams):
eop = End of Period
""",
)
- transform: Literal[None, "chg", "ch1", "pch", "pc1", "pca", "cch", "cca", "log"] = (
- Field(
- default=None,
- description="""
+ transform: Optional[
+ Literal["chg", "ch1", "pch", "pc1", "pca", "cch", "cca", "log"]
+ ] = Field(
+ default=None,
+ description="""
Transformation type
None = No transformation
chg = Change
@@ -92,7 +94,6 @@ class FredSeriesQueryParams(SeriesQueryParams):
cca = Continuously Compounded Annual Rate of Change
log = Natural Log
""",
- )
)
limit: int = Field(description=QUERY_DESCRIPTIONS.get("limit", ""), default=100000)
diff --git a/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py b/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py
index a4fcc6efcca..8892cfd770b 100644
--- a/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py
+++ b/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py
@@ -22,7 +22,7 @@ class GovernmentUSTreasuryPricesQueryParams(TreasuryPricesQueryParams):
"""US Government Treasury Prices Query."""
cusip: Optional[str] = Field(description="Filter by CUSIP.", default=None)
- security_type: Literal[None, "bill", "note", "bond", "tips", "frn"] = Field(
+ security_type: Optional[Literal["bill", "note", "bond", "tips", "frn"]] = Field(
description="Filter by security type.",
default=None,
)
diff --git a/openbb_platform/providers/polygon/openbb_polygon/models/cash_flow.py b/openbb_platform/providers/polygon/openbb_polygon/models/cash_flow.py
index c0d6b366f85..51d7f432a6f 100644
--- a/openbb_platform/providers/polygon/openbb_polygon/models/cash_flow.py
+++ b/openbb_platform/providers/polygon/openbb_polygon/models/cash_flow.py
@@ -64,10 +64,10 @@ class PolygonCashFlowStatementQueryParams(CashFlowStatementQueryParams):
default=False,
description="Whether to include the sources of the financial statement.",
)
- order: Literal[None, "asc", "desc"] = Field(
+ order: Optional[Literal["asc", "desc"]] = Field(
default=None, description="Order of the financial statement."
)
- sort: Literal[None, "filing_date", "period_of_report_date"] = Field(
+ sort: Optional[Literal["filing_date", "period_of_report_date"]] = Field(
default=None, description="Sort of the financial statement."
)
@@ -160,9 +160,9 @@ class PolygonCashFlowStatementFetcher(
@staticmethod
def transform_data(
- query: PolygonCashFlowStatementQueryParams,
+ query: PolygonCashFlowStatementQueryParams, # pylint: disable=unused-argument
data: dict,
- **kwargs: Any,
+ **kwargs: Any, # pylint: disable=unused-argument
) -> List[PolygonCashFlowStatementData]:
"""Return the transformed data."""
transformed_data = []
diff --git a/openbb_platform/providers/tmx/openbb_tmx/models/index_snapshots.py b/openbb_platform/providers/tmx/openbb_tmx/models/index_snapshots.py
index 2052991fff7..e3f81710561 100644
--- a/openbb_platform/providers/tmx/openbb_tmx/models/index_snapshots.py
+++ b/openbb_platform/providers/tmx/openbb_tmx/models/index_snapshots.py
@@ -24,7 +24,7 @@ from pydantic import Field, field_validator
class TmxIndexSnapshotsQueryParams(IndexSnapshotsQueryParams):
"""TMX Index Snapshots Query Params."""
- region: Literal[None, "ca", "us"] = Field(default="ca") # type: ignore
+ region: Optional[Literal["ca", "us"]] = Field(default="ca") # type: ignore
use_cache: bool = Field(
default=True,
description="Whether to use a cached request."