More linting

This commit is contained in:
Theodore Aptekarev
2023-10-11 19:08:02 +02:00
parent 623ea5a78e
commit 68dc4a3fa0
4 changed files with 12 additions and 8 deletions

View File

@@ -52,7 +52,11 @@ class OECDGDPNomFetcher(Fetcher[OECDGDPNomQueryParams, List[OECDGDPNomData]]):
**kwargs: Any,
) -> dict:
unit = "MLN_USD" if query.units == "usd" else "USD_CAP"
url = f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.GDP.TOT.{unit}.A/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod={query.start_date}&endPeriod={query.end_date}"
url = (
f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.GDP.TOT.{unit}.A/OECD"
"?contentType=csv&detail=code&separator=comma&csv-lang=en"
f"&startPeriod={query.start_date}&endPeriod={query.end_date}"
)
data_df = helpers.fetch_data(url, csv_kwargs={"encoding": "utf-8"}, **kwargs)
# Sometimes there is weird unicode characters in the column names, so we need to rename them.
# Even changing the encoding on the fetch doesn't seem to help.

View File

@@ -61,7 +61,11 @@ class OECDGDPRealFetcher(Fetcher[OECDGDPRealQueryParams, List[OECDGDPRealData]])
**kwargs: Any,
) -> dict:
units = {"qoq": "PC_CHGPP", "yoy": "PC_CHGPY", "idx": "IDX"}[query.units]
url = f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.QGDP.{'VOLIDX' if units == 'IDX' else 'TOT'}.{units}.Q/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod={query.start_date}&endPeriod={query.end_date}"
url = (
f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.QGDP.{'VOLIDX' if units == 'IDX' else 'TOT'}"
f".{units}.Q/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en"
f"&startPeriod={query.start_date}&endPeriod={query.end_date}"
)
data_df = helpers.fetch_data(url, csv_kwargs={"encoding": "utf-8"}, **kwargs)
# Sometimes there is weird unicode characters in the column names, so we need to rename them.
# Even changing the encoding on the fetch doesn't seem to help.

View File

@@ -1,9 +1,10 @@
import datetime
import pytest
from openbb_core.app.service.user_service import UserService
from openbb_oecd.models.gdpforecast import OECDGDPForecastFetcher
from openbb_oecd.models.gdpnom import OECDGDPNomFetcher
from openbb_oecd.models.gdpreal import OECDGDPRealFetcher
from openbb_oecd.models.gdpforecast import OECDGDPForecastFetcher
test_credentials = UserService().default_user_settings.credentials.dict()

View File

@@ -540,11 +540,6 @@ def get_gdp(
no_data_message(error=str(e))
return df
print(
f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.GDP.TOT.{units_dict[units]}.A/OECD?contentType=csv&detail=code"
f"&separator=comma&csv-lang=en&startPeriod={start_date}&endPeriod={end_date}"
)
df = df.iloc[:, [0, 5]]
result = pd.DataFrame()