Config
Configure application.
- override(key: str, value: Any) Any[source]
Convenience function that returns the input value unless it is None, in which case the settings value from key is returned.
Examples
>>> from . import override, settings >>> settings['port'] = 8009 >>> print(f"{override('port', 8080)}") 8080
>>> print(f"{override('port', None)}") 8009
- Parameters:
key (str) -- Key to settings value.
value (Any) -- Input value.
- Returns:
value (Any) -- Input value or settings value.
Group and define Pydantic-compatible fields.
- SField(short: str | None = None, **kwargs) Any[source]
Return Pydantic field with augmented JSON schema including a command-line "shortcut" keyword.
Examples
>>> from pydantic_settings import BaseSettings
>>> class Settings(BaseSettings): ... parameter: float = SField( ... short='p', ... description="an arbitrary parameter", ... default=10., ... )
>>> s = Settings(parameter=3.)
>>> s.model_json_schema() {'additionalProperties': False, 'properties': {'parameter': {'default': 10.0, 'description': 'an arbitrary parameter', 'short': 'p', 'title': 'Parameter', 'type': 'number'}}, 'title': 'Settings', 'type': 'object'}
- Parameters:
short (str, optional) -- Shortcut for keyword
**kwargs -- Additional Field arguments.
- Returns:
Pydantic Field with augmented JSON schema.