superwise_api.config
class
Settings(pydantic_settings.main.BaseSettings):
Base class for settings, allowing values to be overridden by environment variables.
This is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose), Heroku and any 12 factor app design.
All the below attributes can be set via model_config
.
Arguments:
- _case_sensitive: Whether environment and CLI variable names should be read with case-sensitivity.
Defaults to
None
. - _nested_model_default_partial_update: Whether to allow partial updates on nested model default object fields.
Defaults to
False
. - _env_prefix: Prefix for all environment variables. Defaults to
None
. - _env_file: The env file(s) to load settings values from. Defaults to
Path('')
, which means that the value frommodel_config['env_file']
should be used. You can also passNone
to indicate that environment variables should not be loaded from an env file. - _env_file_encoding: The env file encoding, e.g.
'latin-1'
. Defaults toNone
. - _env_ignore_empty: Ignore environment variables where the value is an empty string. Default to
False
. - _env_nested_delimiter: The nested env values delimiter. Defaults to
None
. - _env_parse_none_str: The env string value that should be parsed (e.g. "null", "void", "None", etc.)
into
None
type(None). Defaults toNone
type(None), which means no parsing should occur. - _env_parse_enums: Parse enum field names to values. Defaults to
None.
, which means no parsing should occur. - _cli_prog_name: The CLI program name to display in help text. Defaults to
None
if _cli_parse_args isNone
. Otherwse, defaults to sys.argv[0]. - _cli_parse_args: The list of CLI arguments to parse. Defaults to None.
If set to
True
, defaults to sys.argv[1:]. - _cli_settings_source: Override the default CLI settings source with a user defined instance. Defaults to None.
- _cli_parse_none_str: The CLI string value that should be parsed (e.g. "null", "void", "None", etc.) into
None
type(None). Defaults to _env_parse_none_str value if set. Otherwise, defaults to "null" if _cli_avoid_json isFalse
, and "None" if _cli_avoid_json isTrue
. - _cli_hide_none_type: Hide
None
values in CLI help text. Defaults toFalse
. - _cli_avoid_json: Avoid complex JSON objects in CLI help text. Defaults to
False
. - _cli_enforce_required: Enforce required fields at the CLI. Defaults to
False
. - _cli_use_class_docs_for_groups: Use class docstrings in CLI group help text instead of field descriptions.
Defaults to
False
. - _cli_exit_on_error: Determines whether or not the internal parser exits with error info when an error occurs.
Defaults to
True
. - _cli_prefix: The root parser command line arguments prefix. Defaults to "".
- _cli_flag_prefix_char: The flag prefix character to use for CLI optional arguments. Defaults to '-'.
- _cli_implicit_flags: Whether
bool
fields should be implicitly converted into CLI boolean flags. (e.g. --flag, --no-flag). Defaults toFalse
. - _cli_ignore_unknown_args: Whether to ignore unknown CLI args and parse only known ones. Defaults to
False
. - _cli_kebab_case: CLI args use kebab case. Defaults to
False
. - _secrets_dir: The secret files directory or a sequence of directories. Defaults to
None
.
Settings(**kwargs)
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError
][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self
is explicitly positional-only to allow self
as a field name.
model_config =
{'extra': 'ignore', 'arbitrary_types_allowed': True, 'validate_default': True, 'case_sensitive': False, 'env_prefix': '', 'nested_model_default_partial_update': False, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_parse_none_str': None, 'env_parse_enums': None, 'cli_prog_name': None, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_hide_none_type': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_use_class_docs_for_groups': False, 'cli_exit_on_error': True, 'cli_prefix': '', 'cli_flag_prefix_char': '-', 'cli_implicit_flags': False, 'cli_ignore_unknown_args': False, 'cli_kebab_case': False, 'json_file': None, 'json_file_encoding': None, 'yaml_file': None, 'yaml_file_encoding': None, 'toml_file': None, 'secrets_dir': None, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'enable_decoding': True, 'populate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict
][pydantic.config.ConfigDict].
Inherited Members
- pydantic_settings.main.BaseSettings
- settings_customise_sources
- pydantic.main.BaseModel
- model_extra
- model_fields_set
- model_construct
- model_copy
- model_dump
- model_dump_json
- model_json_schema
- model_parametrized_name
- model_post_init
- model_rebuild
- model_validate
- model_validate_json
- model_validate_strings
- dict
- json
- parse_obj
- parse_raw
- parse_file
- from_orm
- construct
- copy
- schema
- schema_json
- validate
- update_forward_refs
- model_fields
- model_computed_fields