Skip to content

Commit

Permalink
optional overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-rivera committed Dec 2, 2024
1 parent 70842ce commit 273687f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/bblocks_data_importers/world_bank/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
10 changes: 6 additions & 4 deletions src/bblocks_data_importers/world_bank/wb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 273687f

Please sign in to comment.