| 46 | self.ini = IniLoader(CORE, parser, overrides=[], core_section=CORE) |
| 47 | |
| 48 | def get(self, key: str, of_type: type[Any]) -> Any: |
| 49 | cache_key = key, of_type |
| 50 | if cache_key in self._cache: |
| 51 | result = self._cache[cache_key] |
| 52 | else: |
| 53 | try: |
| 54 | result = self._load_key(key, of_type) |
| 55 | except KeyError: # just not found |
| 56 | result = None |
| 57 | except Exception as exception: # noqa: BLE001 |
| 58 | logging.warning("%s key %s as type %r failed with %r", self.config_file, key, of_type, exception) |
| 59 | result = None |
| 60 | self._cache[cache_key] = result |
| 61 | return result |
| 62 | |
| 63 | def _load_key(self, key: str, of_type: type[Any]) -> Any: |
| 64 | if self.ini is None: # pragma: no cover # this can only happen if we don't call __bool__ first |