{"id":13534217,"url":"https://github.com/willkg/everett","last_synced_at":"2025-05-15T03:08:03.669Z","repository":{"id":45025236,"uuid":"64695045","full_name":"willkg/everett","owner":"willkg","description":"configuration library for python projects","archived":false,"fork":false,"pushed_at":"2025-05-01T16:30:08.000Z","size":631,"stargazers_count":152,"open_issues_count":4,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-01T17:44:38.120Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willkg.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-08-01T19:20:54.000Z","updated_at":"2025-05-01T16:30:06.000Z","dependencies_parsed_at":"2023-01-23T12:10:13.640Z","dependency_job_id":"c5efd03c-54c3-4571-bbfd-b4b8ca3f322a","html_url":"https://github.com/willkg/everett","commit_stats":{"total_commits":283,"total_committers":9,"mean_commits":"31.444444444444443","dds":"0.10600706713780916","last_synced_commit":"9ea264398a6d8ffdd836bb5af3ca728940486f80"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willkg%2Feverett","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willkg%2Feverett/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willkg%2Feverett/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willkg%2Feverett/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willkg","download_url":"https://codeload.github.com/willkg/everett/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227581,"owners_count":22035664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-01T07:01:28.155Z","updated_at":"2025-05-15T03:07:58.661Z","avatar_url":"https://github.com/willkg.png","language":"Python","funding_links":[],"categories":["Configuration","Python"],"sub_categories":[],"readme":".. NOTE: Make sure to edit the template for this file in docs_tmpl/ and\n.. not the cog-generated version.\n\n=======\nEverett\n=======\n\nEverett is a Python configuration library for your app.\n\n:Code:          https://github.com/willkg/everett\n:Issues:        https://github.com/willkg/everett/issues\n:License:       MPL v2\n:Documentation: https://everett.readthedocs.io/\n\n\nGoals\n=====\n\nGoals of Everett:\n\n1. flexible configuration from multiple configured environments\n2. easy testing with configuration\n3. easy automated documentation of configuration for users\n\nFrom that, Everett has the following features:\n\n* is flexible for your configuration environment needs and supports\n  process environment, env files, dicts, INI files, YAML files,\n  and writing your own configuration environments\n* facilitates helpful error messages for users trying to configure your\n  software\n* has a Sphinx extension for documenting configuration including\n  ``autocomponentconfig`` and ``automoduleconfig`` directives for\n  automatically generating configuration documentation\n* facilitates testing of configuration values\n* supports parsing values of a variety of types like bool, int, lists of\n  things, classes, and others and lets you write your own parsers\n* supports key namespaces\n* supports component architectures\n* works with whatever you're writing--command line tools, web sites, system\n  daemons, etc\n\nEverett is inspired by\n`python-decouple \u003chttps://github.com/henriquebastos/python-decouple\u003e`__\nand `configman \u003chttps://configman.readthedocs.io/en/latest/\u003e`__.\n\n\nInstall\n=======\n\nRun::\n\n    $ pip install everett\n\nSome configuration environments require additional dependencies::\n\n\n    # For INI support\n    $ pip install 'everett[ini]'\n\n    # for YAML support\n    $ pip install 'everett[yaml]'\n\n\nQuick start\n===========\n\nExample:\n\n.. [[[cog\n   import cog\n   with open(\"examples/myserver.py\", \"r\") as fp:\n       cog.outl(\"\\n::\\n\")\n       for line in fp.readlines():\n           if line.strip():\n               cog.out(f\"   {line}\")\n           else:\n               cog.outl()\n   cog.outl()\n   ]]]\n\n::\n\n   # myserver.py\n\n   \"\"\"\n   Minimal example showing how to use configuration for a web app.\n   \"\"\"\n\n   from everett.manager import ConfigManager\n\n   config = ConfigManager.basic_config(\n       doc=\"Check https://example.com/configuration for documentation.\"\n   )\n\n   host = config(\"host\", default=\"localhost\")\n   port = config(\"port\", default=\"8000\", parser=int)\n   debug_mode = config(\n       \"debug\",\n       default=\"False\",\n       parser=bool,\n       doc=\"Set to True for debugmode; False for regular mode\",\n   )\n\n   print(f\"host: {host}\")\n   print(f\"port: {port}\")\n   print(f\"debug_mode: {debug_mode}\")\n\n.. [[[end]]]\n\nThen you can run it:\n\n.. [[[cog\n   import cog\n   import os\n   import subprocess\n   if os.path.exists(\".env\"):\n       os.remove(\".env\")\n   ret = subprocess.run([\"python\", \"examples/myserver.py\"], capture_output=True)\n   cog.outl(\"\\n::\\n\") \n   cog.outl(\"   $ python myserver.py\")\n   for line in ret.stdout.decode(\"utf-8\").splitlines():\n       cog.outl(f\"   {line}\")\n   cog.outl()\n   ]]]\n\n::\n\n   $ python myserver.py\n   host: localhost\n   port: 8000\n   debug_mode: False\n\n.. [[[end]]]\n\nYou can set environment variables to affect configuration:\n\n.. [[[cog\n   import cog\n   import os\n   import subprocess\n   if os.path.exists(\".env\"):\n       os.remove(\".env\")\n   os.environ[\"PORT\"] = \"7000\"\n   cog.outl(\"\\n::\\n\")\n   cog.outl(\"   $ PORT=7000 python myserver.py\")\n   ret = subprocess.run([\"python\", \"examples/myserver.py\"], capture_output=True)\n   for line in ret.stdout.decode(\"utf-8\").splitlines():\n       cog.outl(f\"   {line}\")\n   cog.outl()\n   del os.environ[\"PORT\"]\n   ]]]\n\n::\n\n   $ PORT=7000 python myserver.py\n   host: localhost\n   port: 7000\n   debug_mode: False\n\n.. [[[end]]]\n\nIt checks a ``.env`` file in the current directory:\n\n.. [[[cog\n   import cog\n   import os\n   import subprocess\n   if os.path.exists(\".env\"):\n       os.remove(\".env\")\n   with open(\".env\", \"w\") as fp:\n       fp.write(\"HOST=127.0.0.1\")\n   cog.outl(\"\\n::\\n\")\n   cog.outl(\"   $ echo \\\"HOST=127.0.0.1\\\" \u003e .env\")\n   cog.outl(\"   $ python myserver.py\")\n   ret = subprocess.run([\"python\", \"examples/myserver.py\"], capture_output=True)\n   for line in ret.stdout.decode(\"utf-8\").splitlines():\n       cog.outl(f\"   {line}\")\n   cog.outl()\n   ]]]\n\n::\n\n   $ echo \"HOST=127.0.0.1\" \u003e .env\n   $ python myserver.py\n   host: 127.0.0.1\n   port: 8000\n   debug_mode: False\n\n.. [[[end]]]\n\nIt spits out useful error information if configuration is wrong:\n\n.. [[[cog\n   import cog\n   import os\n   import subprocess\n   if os.path.exists(\".env\"):\n       os.remove(\".env\")\n   os.environ[\"DEBUG\"] = \"foo\"\n   ret = subprocess.run([\"python\", \"examples/myserver.py\"], capture_output=True)\n   stderr = ret.stderr.decode(\"utf-8\").strip()\n   stderr = stderr[stderr.find(\"everett.InvalidValueError\"):]\n   cog.outl(\"\\n::\\n\")\n   cog.outl(\"   $ DEBUG=foo python myserver.py\")\n   cog.outl(\"   \u003ctraceback\u003e\")\n   for line in stderr.splitlines():\n      cog.outl(f\"   {line}\")\n   cog.outl()\n   ]]]\n\n::\n\n   $ DEBUG=foo python myserver.py\n   \u003ctraceback\u003e\n   everett.InvalidValueError: ValueError: 'foo' is not a valid bool value\n   DEBUG requires a value parseable by everett.manager.parse_bool\n   DEBUG docs: Set to True for debugmode; False for regular mode\n   Project docs: Check https://example.com/configuration for documentation.\n\n.. [[[end]]]\n\nYou can test your code using ``config_override`` in your tests to test various\nconfiguration values:\n\n.. [[[cog\n   import cog\n   cog.outl(\"\\n::\\n\")\n   with open(\"examples/testdebug.py\", \"r\") as fp:\n       for line in fp.readlines():\n           cog.out(f\"   {line}\")\n   cog.outl()\n   ]]]\n\n::\n\n   # testdebug.py\n   \n   \"\"\"\n   Minimal example showing how to override configuration values when testing.\n   \"\"\"\n   \n   import unittest\n   \n   from everett.manager import ConfigManager, config_override\n   \n   \n   class App:\n       def __init__(self):\n           config = ConfigManager.basic_config()\n           self.debug = config(\"debug\", default=\"False\", parser=bool)\n   \n   \n   class TestDebug(unittest.TestCase):\n       def test_debug_on(self):\n           with config_override(DEBUG=\"on\"):\n               app = App()\n               self.assertTrue(app.debug)\n   \n       def test_debug_off(self):\n           with config_override(DEBUG=\"off\"):\n               app = App()\n               self.assertFalse(app.debug)\n   \n   \n   if __name__ == \"__main__\":\n       unittest.main()\n\n.. [[[end]]]\n\nRun that:\n\n.. [[[cog\n   import cog\n   import os\n   import subprocess\n   ret = subprocess.run([\"python\", \"examples/testdebug.py\"], capture_output=True)\n   stderr = ret.stderr.decode(\"utf-8\").strip()\n   cog.outl(\"\\n::\\n\")\n   cog.outl(\"   $ python testdebug.py\")\n   for line in stderr.splitlines():\n       cog.outl(f\"   {line}\")\n   cog.outl()\n   ]]]\n\n::\n\n   $ python testdebug.py\n   ..\n   ----------------------------------------------------------------------\n   Ran 2 tests in 0.000s\n   \n   OK\n\n.. [[[end]]]\n\nThat's perfectly fine for a `12-Factor \u003chttps://12factor.net/\u003e`__ app.\n\nWhen you outgrow that or need different variations of it, you can switch to\ncreating a ``ConfigManager`` instance that meets your needs.\n\n\nWhy not other libs?\n===================\n\nMost other libraries I looked at had one or more of the following issues:\n\n* were tied to a specific web app framework\n* didn't allow you to specify configuration sources\n* provided poor error messages when users configure things wrong\n* had a global configuration object\n* made it really hard to override specific configuration when writing tests\n* had no facilities for autogenerating configuration documentation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillkg%2Feverett","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillkg%2Feverett","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillkg%2Feverett/lists"}