From 273687f9eb63e3ac5e818286c2b2315eb521da58 Mon Sep 17 00:00:00 2001 From: Jorge Rivera Date: Mon, 2 Dec 2024 18:13:43 +0100 Subject: [PATCH] optional overrides --- src/bblocks_data_importers/world_bank/ids.py | 6 ------ src/bblocks_data_importers/world_bank/wb_api.py | 10 ++++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bblocks_data_importers/world_bank/ids.py b/src/bblocks_data_importers/world_bank/ids.py index a80baa4..cb19f3d 100644 --- a/src/bblocks_data_importers/world_bank/ids.py +++ b/src/bblocks_data_importers/world_bank/ids.py @@ -69,12 +69,6 @@ def __init__(self): super().__init__() self.set_database(6) - def set_database(self, database: int) -> None: - """Overrides the database to be used. This cannot be done with the IDS class.""" - raise ValueError( - "The database cannot be changed for the International Debt Statistics database." - ) - @property def latest_update(self): return self.api.source.info(id=self.config["database"]).items[0]["lastupdated"] diff --git a/src/bblocks_data_importers/world_bank/wb_api.py b/src/bblocks_data_importers/world_bank/wb_api.py index 42e9a1e..6d70cbf 100644 --- a/src/bblocks_data_importers/world_bank/wb_api.py +++ b/src/bblocks_data_importers/world_bank/wb_api.py @@ -389,8 +389,8 @@ def clear_cache(self) -> None: def get_data( self, series: str | list[str], - years: Optional[Literal["all"] | int | list[int] | Iterable] = "all", - economies: Optional[str | list[str] | Literal["all"]] = "all", + years: Optional[Literal["all"] | int | list[int] | Iterable] = None, + economies: Optional[str | list[str] | Literal["all"]] = None, config: Optional[dict] = None, ) -> pd.DataFrame: """Fetches and returns data for the specified indicator series. @@ -418,8 +418,10 @@ def get_data( economies = [economies] # Set config overrides - config["economies"] = economies - config["years"] = years + if years is not None: + config["years"] = years + if economies is not None: + config["economies"] = economies # Check that all configuration keys are valid if not set(config.keys()).issubset(self._valid_config_keys):