Package: everett
Everett is a Python configuration library for your app.Code:https://github.com/willkg/everettIssues:https://github.com/willkg/everett/issuesLicense:MPL v2Documentation:https://everett.readthedocs.io/GoalsGoals of Everett:flexible configuration from multiple configured environmentseasy testing with configurationeasy automated documentation of configuration for usersFrom that, Everett has the following features:is flexible for your configuration environment needs and supports
process environment, env files, dicts, INI files, YAML files,
and writing your own configuration environmentsfacilitates helpful error messages for users trying to configure your
softwarehas a Sphinx extension for documenting configuration includingautocomponentconfigandautomoduleconfigdirectives for
automatically generating configuration documentationfacilitates testing of configuration valuessupports parsing values of a variety of types like bool, int, lists of
things, classes, and others and lets you write your own parserssupports key namespacessupports component architecturesworks with whatever you’re writing–command line tools, web sites, system
daemons, etcEverett is inspired bypython-decoupleandconfigman.InstallRun:$ pip install everettSome configuration environments require additional dependencies:# For INI support
$ pip install 'everett[ini]'

# for YAML support
$ pip install 'everett[yaml]'Additionally, if you want to use the Sphinx extension to document
your configuration, you need to add Sphinx:# to use the Sphinx extension
$ pip install 'everett[sphinx]'Quick startExample:# myserver.py

"""
Minimal example showing how to use configuration for a web app.
"""

from everett.manager import ConfigManager

config = ConfigManager.basic_config(
    doc="Check https://example.com/configuration for documentation."
)

host = config("host", default="localhost")
port = config("port", default="8000", parser=int)
debug_mode = config(
    "debug",
    default="False",
    parser=bool,
    doc="Set to True for debugmode; False for regular mode",
)

print(f"host: {host}")
print(f"port: {port}")
print(f"debug_mode: {debug_mode}")Then you can run it:$ python myserver.py
host: localhost
port: 8000
debug_mode: FalseYou can set environment variables to affect configuration:$ PORT=7000 python myserver.py
host: localhost
port: 7000
debug_mode: FalseIt checks a.envfile in the current directory:$ echo "HOST=127.0.0.1" > .env
$ python myserver.py
host: 127.0.0.1
port: 8000
debug_mode: FalseIt spits out useful error information if configuration is wrong:$ DEBUG=foo python myserver.py
<traceback>
everett.InvalidValueError: ValueError: 'foo' is not a valid bool value
DEBUG requires a value parseable by everett.manager.parse_bool
DEBUG docs: Set to True for debugmode; False for regular mode
Project docs: Check https://example.com/configuration for documentation.You can test your code usingconfig_overridein your tests to test various
configuration values:# testdebug.py

"""
Minimal example showing how to override configuration values when testing.
"""

import unittest

from everett.manager import ConfigManager, config_override


class App:
    def __init__(self):
        config = ConfigManager.basic_config()
        self.debug = config("debug", default="False", parser=bool)


class TestDebug(unittest.TestCase):
    def test_debug_on(self):
        with config_override(DEBUG="on"):
            app = App()
            self.assertTrue(app.debug)

    def test_debug_off(self):
        with config_override(DEBUG="off"):
            app = App()
            self.assertFalse(app.debug)


if __name__ == "__main__":
    unittest.main()Run that:..
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OKThat’s perfectly fine for a12-Factorapp.When you outgrow that or need different variations of it, you can switch to
creating aConfigManagerinstance that meets your needs.Why not other libs?Most other libraries I looked at had one or more of the following issues:were tied to a specific web app frameworkdidn’t allow you to specify configuration sourcesprovided poor error messages when users configure things wronghad a global configuration objectmade it really hard to override specific configuration when writing testshad no facilities for autogenerating configuration documentationHistory3.3.0 (in development)Backwards incompatible changes:Dropped support for Python 3.7. (#220)Fixes and features:Added support for Python 3.12 (#221)Fix env file parsing in regards to quotes. (#230)3.2.0 (March 21st, 2023)Fixes and features:Implementdefault_if_emptyargument which will return the default value
(if specified) if the value is the empty string. (#205)Implementparse_time_periodparser for converting time periods like “10m4s”
into the total number of seconds that represents.>>> from everett.manager import parse_time_period
>>> parse_time_period("4m")
240(#203)Implementparse_data_sizeparser for converting values like “40gb” into
the total number of bytes that represents.>>> from everett.manager import parse_data_size
>>> parse_time_period("40gb")
40000000000(#204)Fix anUnboundLocalErrorwhen usingautomoduleconfigand providing a
Python dotted path to a thing that either kicks up anImportErroror
doesn’t exist. Now it raises a more helpful error. (#201)3.1.0 (October 26th, 2022)Fixes and features:Add support for Python 3.11. (#187)Addraise_configuration_errormethod onConfigManager. (#185)Improveautomoduleconfigto walk the whole AST and document configuration
set by assign:SOMEVAR = _config("somevar")and dict:SOMEGROUP = {
    "SOMEVAR": _config("somevar"),
}(#184)Fix options not showing up on ReadTheDocs. (#186)3.0.0 (January 13th, 2022)Backwards incompatible changes:Dropped support for Python 3.6. (#176)DroppedautocomponentSphinx directive in favor ofautocomponentconfig.Fixes and features:Add support for Python 3.10. (#173)Rework namespaces so that you can apply a namespace (with_namespace())
after binding a component (with_options()) (#175)Overhauled, simplified, and improved documentation. Files with example output
are now generated usingcog.Rewrite Sphinx extension.This now supports manually documenting configuration usingeverett:componentandeverett:optiondirectives.This adds:everett:component:and:everett:option:roles for linking
to specific configuration in the docs.It also addshautocomponentconfigandautomoduleconfigdirectives for
automatically generating documentation.When using these directives, items are added to the index and everything is
linkable making it easier to find and talk to users about specific
configuration items. (#172)2.0.1 (August, 23rd, 2021)Fixes:Fix Sphinx warning about roles in Everett sphinxext. (#165)Fixget_runtime_configto work with slots (#166)2.0.0 (July 27th, 2021)Backwards incompatible changes:This radically reduces the boilerplate required to define components. It also
improves the connections between things so it’s easier to:determine the configuration required for a single component (taking into
account superclasses, overriding, etc)determine the runtime configuration for a component tree given a
configuration managerPreviously, components needed to subclass RequiredConfigMixin and provide a
“required_config” class attribute. Something like this:from everett.component import RequiredConfigMixin, ConfigOptions

class SomeClass(RequiredConfigMixin):
    required_config = ConfigOptions()
    required_config.add_option(
        "some_option",
        default="42",
    )That’s been slimmed down and now looks like this:from everett.manager import Option

class SomeClass:
    class Config:
        some_option = Option(default="42")That’s much simpler and the underlying implementation code is less tangled
and complex, too.If you usedeverett.component.RequiredConfigMixinoreverett.component.ConfigOptions, you’ll need to update your classes.If you didn’t use those things, then you don’t have to make any changes.See the documentation on components for how it all works now.Changed the way configuration variables are referred to in configuration
error messages. Previously, I tried to use a general way “namespace=something
key=somethingelse” but that’s confusing and won’t match up with project
documentation.I changed it to the convention used in the process environment and
env files. For example,FOO_BAR.If you use INI or YAML for configuration, you can specify amsg_builderargument when you build theConfigManagerand build error messages
tailored to your users.Fixes:Switch tosrc/repository layout.Added type annotations and type checking during CI. (#155)Standardized on f-strings across the codebase.Switched Sphinx theme.Update of documentation, fleshed out and simplified examples, cleaned up
language, reworked structure of API section (previously called Library or
some unhelpful thing like that), etc.1.0.3 (October 28th, 2020)Backwards incompatible changes:Dropped support for Python 3.4. (#96)Dropped support for Python 3.5. (#116)Fixes:Add support for Python 3.7. (#68)Add support for Python 3.8. (#102)Add support for Python 3.9. (#117)Reformatted code with Black, added Makefile, switched to GitHub Actions.Fixget_runtime_config()to infer namespaces. (#118)FixRemovedInSphinx50Warning. (#115)Documentation fixes and clarifications.1.0.2 (February 22nd, 2019)Fixes:Improve documentation.Fix problems when there are nestedBoundConfigs. Now they work
correctly. (#90)Add “meta” to options letting you declare additional data on the option
when you’re adding it.For example, this lets you do things like mark options as “secrets”
so that you know which ones to******out when logging your
configuration. (#88)1.0.1 (January 8th, 2019)Fixes:Fix documentation issues.Package missingeverett.ext. Thank you, dsblank! (#84)1.0.0 (January 7th, 2019)Backwards incompatible changes:Dropped support for Python 2.7. Everett no longer supports Python 2. (#73)Dropped support for Python 3.3 and added support for Python 3.7. Thank you,
pjz! (#68)MovedConfigIniEnvto a different module. Now you need to import it
like this:from everett.ext.inifile import ConfigIniEnv(#79)Features:Everett now logs configuration discovery in theeverettlogger at thelogging.DEBUGlevel. This is helpful for trouble-shooting some kinds of
issues. (#74)Everett now has a YAML configuration environment. In order to use it, you
need to install its requirements:$ pip install everett[yaml]Then you can import it like this:from everett.ext.yamlfile import ConfigYamlEnv(#72)Fixes:Everett no longer requiresconfigobj–it’s now optional. If you useConfigIniEnv, you can install it with:$ pip install everett[ini](#79)Fixed list parsing and file discovery in ConfigIniEnv so they match the
docs and are more consistent with other envs. Thank you, apollo13! (#71)Added a.basic_config()for fast opinionated setup that uses the
process environment and a.envfile in the current working directory.Switching to semver.0.9 (April 7th, 2017)Changed:Rewrite Sphinx extension. The extension is now in theeverett.sphinxextmodule and the directive is now.. autocomponent::. It generates better
documentation and it now indexes Everett components and options.This is backwards-incompatible. You will need to update your Sphinx
configuration and documentation.Changed theHISTORY.rststructure.Changed the repr foreverett.NO_VALUEto"NO_VALUE".InvalidValueErrorandConfigurationMissingErrornow havenamespace,key, andparserattributes allowing you to build your
own messages.Fixed:Fix an example in the docs where the final key was backwards. Thank you, pjz!Documentation fixes and updates.0.8 (January 24th, 2017)Added:Add:namespace:and:case:arguments to autoconfig directive. These
make it easier to cater your documentation to your project’s needs.Add support for Python 3.6.Minor documentation fixes and updates.0.7 (January 5th, 2017)Added:Feature: You can now include documentation hints and urls forConfigManagerobjects and config options. This will make it easier for
your users to debug configuration errors they’re having with your software.Fixed:FixListOfso it returns empty lists rather than a list with a single
empty string.Documentation fixes and updates.0.6 (November 28th, 2016)Added:AddRequiredConfigMixin.get_runtime_config()which returns the runtime
configuration for a component or tree of components. This lets you print
runtime configuration at startup, generate INI files, etc.AddConfigObjEnvwhich lets you use an object for configuration. This
works with argparse’s Namespace amongst other things.Changed:Change:show-docstring:to take an optional value which is the attribute
to pull docstring content from. This means you don’t have to mix programming
documentation with user documentation–they can be in different attributes.Improve configuration-related exceptions. With Python 3, configuration errors
all derive fromConfigurationErrorand have helpful error messages that
should make it clear what’s wrong with the configuration value. With Python 2,
you can get other kinds of Exceptions thrown depending on the parser used, but
configuration error messages should still be helpful.Documentation fixes and updates.0.5 (November 8th, 2016)Added:Add:show-docstring:flag toautoconfigdirective.Add:hide-classname:flag toautoconfigdirective.Changed:RewriteConfigIniEnvto use configobj which allows for nested sections in
INI files. This also allows you to specify multiple INI files and have later
ones override earlier ones.Fixed:FixautoconfigSphinx directive and add tests–it was all kinds of broken.Documentation fixes and updates.0.4 (October 27th, 2016)Added:Addraw_valueargument to config calls. This makes it easier to write code
that prints configuration.Fixed:Fixlistify(None)to return[].Documentation fixes and updates.0.3.1 (October 12th, 2016)Fixed:Fixalternate_keyswith components. Previously it worked for everything
but components. Now it works with components, too.Documentation fixes and updates.0.3 (October 6th, 2016)Added:AddConfigManager.from_dict()shorthand for building configuration
instances.Add.get_namespace()toConfigManagerand friends for getting
the complete namespace for a given config instance as a list of strings.Addalternate_keysto config call. This lets you specify a list of keys in
order to try if the primary key doesn’t find a value. This is helpful for
deprecating keys that you used to use in a backwards-compatible way.Addroot:prefix to keys allowing you to look outside of the current
namespace and at the configuration root for configuration values.Changed:MakeConfigDictEnvcase-insensitive to keys and namespaces.Documentation fixes and updates.0.2 (August 16th, 2016)Added:AddConfigEnvFileEnvfor supporting.envfiles. Thank you, Paul!Add “on” and “off” as valid boolean values. This makes it easier to use config
for feature flippers. Thank you, Paul!Changed:ChangeConfigIniEnvto take a single path or list of paths. Thank you,
Paul!MakeNO_VALUEfalsy.Fixed:Fix__call__returning None–it should returnNO_VALUE.Lots of docs updates: finished the section about making your own parsers, added
a section on using dj-database-url, added a section on django-cache-url and
expanded on existing examples.0.1 (August 1st, 2016)Initial writing.