Module xsettings.env_settings
Classes
class EnvVarSettings (retrievers: Optional[Union[List[SettingsRetrieverProtocol], SettingsRetrieverProtocol]] = None,
**kwargs)-
Expand source code
class EnvVarSettings(BaseSettings, default_retrievers=EnvVarRetriever()): """ Base subclass of `xsettings.settings.BaseSettings` with the default retriever set as the `xsettings.retrievers.EnvVarRetriever`. This means when a settings field is defined without a retriever it will use the `xsettings.retrievers.EnvVarRetriever` by default to retriever its value. The `xsettings.retrievers.EnvVarRetriever` will check `os.environ` dict for the values. It first tries with the plain name of the field. If a value is not found (not even an empty string) it will next try looking up the env-var by upper-casing the name (as it's extremely common to use all upper-case vars for environmental var names). If it still can't be found then None will be returned and the system will look at the next retriever and/or the default value for the field as necessary/needed. """ passBase subclass of
BaseSettingswith the default retriever set as thexsettings.retrievers.EnvVarRetriever.This means when a settings field is defined without a retriever it will use the
xsettings.retrievers.EnvVarRetrieverby default to retriever its value.The
xsettings.retrievers.EnvVarRetrieverwill checkos.environdict for the values.It first tries with the plain name of the field.
If a value is not found (not even an empty string) it will next try looking up the env-var by upper-casing the name (as it's extremely common to use all upper-case vars for environmental var names).
If it still can't be found then None will be returned and the system will look at the next retriever and/or the default value for the field as necessary/needed.
Set attributes to values that are passed via key-word arguments, these are the initial values for the settings instance your creating; they are set directly on the instance as if you did this:
# These two statements do the same thing: obj = SomeSettings(some_keyword_arg="hello") obj = SomeSettings() obj.some_keyword_arg="hello"- Args
- -----=
retrievers- can be used to populate new instance's retrievers,
see
BaseSettings.settings__instance_retrievers.Ancestors
Static methods
def __init_subclass__(thread_sharable: bool | DefaultType = Default,
remove_between_unittests: bool | DefaultType = Default,
attributes_to_skip_while_copying: Iterable[str] | None = Default,
lazily_create_for: Type[Dependency] | Iterable[Type[Dependency]] | DefaultType = Default,
lazily_create_for_abs: bool | DefaultType = Default,
inject_for: Type[Dependency] | Iterable[Type[Dependency]] | DefaultType = Default,
**kwargs)-
Inherited from:
BaseSettings.__init_subclass__- Args
- -----=
remove_between_unittests- If
False(default): Dependency will be removed from global context before/after as each individual …
def grab() ‑> ~T-
Inherited from:
BaseSettings.grabGets a potentially shared dependency from the current
udpend.context.XContext… def proxy() ‑> ~R-
Inherited from:
BaseSettings.proxyReturns a proxy-object, that when and attribute is asked for, it will proxy it to the current object of
cls… def proxy_attribute(attribute_name: str) ‑> Any-
Inherited from:
BaseSettings.proxy_attributeReturns a proxy-object, that when and attribute is asked for, it will proxy it to the current attribute value on the current object of
cls…
Instance variables
var obj-
Inherited from:
BaseSettings.objclass property/attribute that will return the current dependency for the subclass it's asked on by calling
Dependency.grab, passing no extra … prop settings__instance_retrievers : List[SettingsRetrieverProtocol]-
Inherited from:
BaseSettings.settings__instance_retrieversYou can add one or more retrievers to this
instanceof settings (won't modify default_retrievers for the entire class, only modifies this specific …
Methods
def __call__(self, func)-
Inherited from:
BaseSettings.__call__This makes Resource subclasses have an ability to be used as function decorators by default unless this method is overriden to provide some other …
def __copy__(self)-
Inherited from:
BaseSettings.__copy__Basic shallow copy protection (I am wondering if I should just remove this default copy code) …