Get a setting value as a list. If the setting original type is a list, a copy of it will be returned. If it's a string it will be split by ",". If it is an empty string, an empty list will be returned. For example, settings populated through environment variables se
(
self, name: _SettingsKey, default: list[Any] | None = None
)
| 227 | return float(self.get(name, default)) |
| 228 | |
| 229 | def getlist( |
| 230 | self, name: _SettingsKey, default: list[Any] | None = None |
| 231 | ) -> list[Any]: |
| 232 | """ |
| 233 | Get a setting value as a list. If the setting original type is a list, |
| 234 | a copy of it will be returned. If it's a string it will be split by |
| 235 | ",". If it is an empty string, an empty list will be returned. |
| 236 | |
| 237 | For example, settings populated through environment variables set to |
| 238 | ``'one,two'`` will return a list ['one', 'two'] when using this method. |
| 239 | |
| 240 | :param name: the setting name |
| 241 | :type name: str |
| 242 | |
| 243 | :param default: the value to return if no setting is found |
| 244 | :type default: object |
| 245 | """ |
| 246 | value = self.get(name, default or []) |
| 247 | if not value: |
| 248 | return [] |
| 249 | if isinstance(value, str): |
| 250 | value = value.split(",") |
| 251 | return list(value) |
| 252 | |
| 253 | def getdict( |
| 254 | self, name: _SettingsKey, default: dict[Any, Any] | None = None |
no test coverage detected