(self, *, config_class: type | None = None, **kwargs)
| 245 | _DEFAULT_CONFIG_CLASS: type = BaseModelConfig |
| 246 | |
| 247 | def __init__(self, *, config_class: type | None = None, **kwargs): |
| 248 | self.config = (config_class or self._DEFAULT_CONFIG_CLASS)(**kwargs) |
| 249 | self._last_request_metrics: dict[str, int] = {k: 0 for k in _REQUEST_METRIC_KEYS} |
| 250 | self._last_usage_metrics: dict[str, int] = {k: 0 for k in _USAGE_METRIC_KEYS} |
| 251 | self._cumulative_request_metrics: dict[str, int] = dict(self._last_request_metrics) |
| 252 | self._cumulative_usage_metrics: dict[str, int] = dict(self._last_usage_metrics) |
| 253 | |
| 254 | if self._API_KEY_FIELD: |
| 255 | if not getattr(self.config, self._API_KEY_FIELD, ""): |
| 256 | setattr(self.config, self._API_KEY_FIELD, os.environ.get(self._ENV_VAR, "")) |
| 257 | if not getattr(self.config, self._API_KEY_FIELD, ""): |
| 258 | raise RuntimeError(f"Missing {self._ENV_VAR}.") |
| 259 | |
| 260 | # ---- subclass extension points ------------------------------------------------ |
| 261 |
nothing calls this directly
no outgoing calls
no test coverage detected