Update the configuration with custom values. Dict-valued keys (e.g. ``data_vendors``) are merged one level deep so a partial update like ``{"data_vendors": {"core_stock_apis": "alpha_vantage"}}`` keeps the other nested keys from the default; scalar keys are replaced.
(config: dict)
| 14 | |
| 15 | |
| 16 | def set_config(config: dict): |
| 17 | """Update the configuration with custom values. |
| 18 | |
| 19 | Dict-valued keys (e.g. ``data_vendors``) are merged one level deep so a |
| 20 | partial update like ``{"data_vendors": {"core_stock_apis": "alpha_vantage"}}`` |
| 21 | keeps the other nested keys from the default; scalar keys are replaced. |
| 22 | """ |
| 23 | global _config |
| 24 | initialize_config() |
| 25 | incoming = deepcopy(config) |
| 26 | for key, value in incoming.items(): |
| 27 | if isinstance(value, dict) and isinstance(_config.get(key), dict): |
| 28 | _config[key].update(value) |
| 29 | else: |
| 30 | _config[key] = value |
| 31 | |
| 32 | |
| 33 | def get_config() -> dict: |