{"id":16087990,"url":"https://github.com/prostomarkeloff/betterconf","last_synced_at":"2025-07-22T08:03:52.514Z","repository":{"id":56566322,"uuid":"229990909","full_name":"prostomarkeloff/betterconf","owner":"prostomarkeloff","description":"Minimalistic Python library for your configs.","archived":false,"fork":false,"pushed_at":"2025-01-21T12:36:31.000Z","size":83,"stargazers_count":47,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-06T00:54:16.411Z","etag":null,"topics":["config","env","python","python-config","python-configs","unix-way"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prostomarkeloff.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2019-12-24T18:50:15.000Z","updated_at":"2025-06-09T02:20:52.000Z","dependencies_parsed_at":"2024-12-27T12:00:47.455Z","dependency_job_id":null,"html_url":"https://github.com/prostomarkeloff/betterconf","commit_stats":null,"previous_names":["prostomarkeloff/betterconf","fscdev/betterconf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/prostomarkeloff/betterconf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fbetterconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fbetterconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fbetterconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fbetterconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prostomarkeloff","download_url":"https://codeload.github.com/prostomarkeloff/betterconf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fbetterconf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266454828,"owners_count":23931344,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["config","env","python","python-config","python-configs","unix-way"],"created_at":"2024-10-09T13:34:33.207Z","updated_at":"2025-07-22T08:03:52.489Z","avatar_url":"https://github.com/prostomarkeloff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Configs in Python made smooth and simple\n\nBetterconf (**better config**) is a Python library for project configuration\nmanagement. It allows you define your config like a regular Python class.\n\nFeatures:\n\n* Easy to hack.\n* Less boilerplate.\n* Minimal code to do big things.\n* Zero dependencies. Only vanilla Python \u003e=3.11\n\nBetterconf is heavily typed, so your editors and typecheckers will be happy with it.\n\nIt's not that huge as Pydantic, so takes like 5 minutes to dive into.\n\nBetterconf is highly customizable, so you can do anything with it.\n\n## Installation\n\nI recommend you to use poetry:\n\n```sh\npoetry add betterconf\n```\n\nHowever, you can use pip:\n\n```sh\npip install betterconf\n```\n\n## How to?\n\nBetterconf is very intuitive, so you don't need special knowledge to use it. We'll cover the basics.\n\nThe most simple config will look like this:\n```python\nfrom betterconf import betterconf\n\n@betterconf\nclass Config:\n    LOGIN: str\n    PASSWORD: str\n\ncfg = Config()\nprint(config.LOGIN)\n```\n\nLet's dive into what it does. By default, betterconf uses `EnvironmentProvider`, getting values with `os.getenv`,\nso you can run this example with `LOGIN=vasya PASSWORD=admin python config.py` and simply get your login.\n\n\nThere is a very usable thing in our fancy-web-world, called `.env`s. Betterconf, since 4.5.0 automatically supports them out-of-the-box! See it:\n\n```python\nfrom betterconf import betterconf, DotenvProvider\n\n# here betterconf gets values from `.env` file, you can change name or the path passing it as the first\n# argument to provider.\n# also, auto_load lets you not to write `provider.load_into_env` (loading variables to os.environ)\n# or `provider.load_into_provider()` (loading them into the provider's inner storage).\n@betterconf(provider=DotenvProvider(auto_load=True))\nclass Config:\n    val1: int\n    val2: str\n    name: str\n\ncfg = Config()\nprint(cfg.val1, cfg.val2, cfg.name)\n```\n\nYour `.env` then looks like this:\n\n```\nname=\"John Wicked\"\nval1=12\nval2=\"testing value\"\n```\n\n\nBut what if you need a different provider? Betterconf lets you set providers as for config itself and for each field respectively.\n\n```python\nimport json\nfrom betterconf import Alias\nfrom betterconf import betterconf, field\nfrom betterconf import JSONProvider, AbstractProvider\n\nsample_json_config = json.dumps({\"field\": {\"from\": {\"json\": 123}}})\n\n# our provider, that just gives the name of field back\nclass NameProvider(AbstractProvider):\n    def get(self, name: str) -\u003e str:\n        return name\n\n@betterconf(provider=NameProvider())\nclass Config:\n    # value will be got from NameProvider and will simply be `my_fancy_name`\n    my_fancy_name: str\n    # here we get value from JSONProvider; the default nested_access is '.'\n    field_from_json: Alias[int, \"field::from::json\"] = field(provider=JSONProvider(sample_json_config, nested_access=\"::\"))\n\n```\n\nBetterconf casts primitive types itself, they include list, float, str, int. But if you need specific caster, say for complex object, you can write your own.\n\n```python\nfrom betterconf import betterconf\nfrom betterconf import AbstractCaster, field\n\nclass DashesToDotsCaster(AbstractCaster):\n    def cast(self, val: str) -\u003e str:\n        return val.replace(\"_\", \".\")\n\n@betterconf\nclass Config:\n    simple_int: int\n    value: str = field(caster=DashesToDotsCaster())\n\nprint(Config(value=\"privet_mir\", simple_int=\"55666\").value)\n```\n\nSubconfigs and referencing one field in another declaration is also available. Check out examples folder.\n\n## License\nThis project is licensed under MIT License.\n\nSee [LICENSE](LICENSE) for details.\n\n\nMade with :heart: by [prostomarkeloff](https://github.com/prostomarkeloff) and our contributors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprostomarkeloff%2Fbetterconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprostomarkeloff%2Fbetterconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprostomarkeloff%2Fbetterconf/lists"}