{"id":13501214,"url":"https://github.com/ajatkj/typed_configparser","last_synced_at":"2025-12-25T23:11:47.239Z","repository":{"id":218733340,"uuid":"746622877","full_name":"ajatkj/typed_configparser","owner":"ajatkj","description":"A fully typed configparser built on top of configparser","archived":false,"fork":false,"pushed_at":"2024-03-09T05:36:42.000Z","size":67,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-31T20:39:22.237Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ajatkj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2024-01-22T11:33:44.000Z","updated_at":"2024-09-06T09:20:52.000Z","dependencies_parsed_at":"2024-03-08T21:24:31.513Z","dependency_job_id":"3cc94675-a562-4f57-b8ee-a1699994e95c","html_url":"https://github.com/ajatkj/typed_configparser","commit_stats":null,"previous_names":["ajatkj/typed_configparser"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajatkj%2Ftyped_configparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajatkj%2Ftyped_configparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajatkj%2Ftyped_configparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajatkj%2Ftyped_configparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajatkj","download_url":"https://codeload.github.com/ajatkj/typed_configparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162092,"owners_count":20733351,"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":[],"created_at":"2024-07-31T22:01:29.406Z","updated_at":"2025-12-25T23:11:42.179Z","avatar_url":"https://github.com/ajatkj.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/ajatkj/typed_configparser/main/assets/logo.png\" alt=\"Description of the image\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/ajatkj/typed_configparser/actions?query=workflow%3ATest+event%3Apush+branch%3Amain\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/ajatkj/typed_configparser/tests.yml?branch=main\u0026event=push\u0026style=flat-square\u0026label=test\u0026color=%2334D058\" alt=\"Test\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://app.codecov.io/gh/ajatkj/typed_configparser/tree/main/\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://img.shields.io/codecov/c/github/ajatkj/typed_configparser?color=%2334D058\u0026style=flat-square\" alt=\"Coverage\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/typed-configparser\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://img.shields.io/pypi/v/typed-configparser?color=%2334D058\u0026label=pypi%20package\u0026style=flat-square\" alt=\"Package version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/typed-configparser\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://img.shields.io/pypi/pyversions/typed-configparser?color=%2334D058\u0026style=flat-square\" alt=\"Supported Python versions\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# typed-configparser\n\ntyped-configparser is an extension of the standard configparser module with support for typed configurations using dataclasses.\nIt leverages Python's type hints and dataclasses to provide a convenient way of parsing and validating configuration files.\n\n## Features\n\n✓ Fully typed.\u003cbr /\u003e\n✓ Use dataclasses to parse the configuration file.\u003cbr /\u003e\n✓ Support for almost all python built-in data types - `int`, `float`, `str`, `list`, `tuple`, `dict` and complex data types using `Union` and `Optional`.\u003cbr /\u003e\n✓ Supports almost all features of dataclasses including field level init flag, **post_init** method, InitVars and more.\u003cbr /\u003e\n✓ Built on top of `configparser`, hence retains all functionalities of `configparser`.\u003cbr /\u003e\n✓ Support for optional values (optional values are automatically set to `None` if not provided).\u003cbr /\u003e\n✓ Smarter defaults (see below).\n\n## Installation\n\nYou can install `typed_configparser` using `pip`:\n\n```sh\npip install typed-configparser\n```\n\n## Usage\n\n`examples/basic.py`\n\n```py3\n# This is a complete example and should work as is\n\nfrom typing import List\nfrom typed_configparser import ConfigParser\nfrom dataclasses import dataclass\n\n\n@dataclass\nclass BASIC:\n    option1: int\n    option2: str\n    option3: float\n    option4: List[str]\n\n\nconfig = \"\"\"\n[BASIC]\noption1 = 10\noption2 = value2\noption3 = 5.2\noption4 = [foo,bar]\n\"\"\"\n\nparser = ConfigParser()\nparser.read_string(config)\nsection = parser.parse_section(using_dataclass=BASIC)\n\nprint(section)\n```\n\n```py3\nBASIC(option1=10, option2=value2, option3=5.2, option4=['foo', 'bar'])\n```\n\n`examples/unions_and_optionals.py`\n\n```py3\n# This is a complete example and should work as is\n\nfrom typing import List, Union, Optional, Dict, Tuple\nfrom typed_configparser import ConfigParser\nfrom dataclasses import dataclass, field\n\n\n@dataclass\nclass DEFAULT_EXAMPLE:\n    option1: int\n    option2: Union[List[Tuple[str, str]], List[int]]\n    option3: Dict[str, str] = field(default_factory=lambda: {\"default_key\": \"default_value\"})\n    option4: Optional[float] = None\n\n\nconfig = \"\"\"\n[DEFAULT]\noption1 = 20\noption2 = default_value2\n\n[MY_SECTION_1]\noption2 = [10,20]\noption4 = 5.2\n\n[MY_SECTION_2]\noption2 = [(value2a, value2b), (value2c, value2b), (value2c, value2d)]\noption3 = {key: value}\noption4 = none\n\"\"\"\n\nparser = ConfigParser()\nparser.read_string(config)\nmy_section_1 = parser.parse_section(using_dataclass=DEFAULT_EXAMPLE, section_name=\"MY_SECTION_1\")\nmy_section_2 = parser.parse_section(using_dataclass=DEFAULT_EXAMPLE, section_name=\"MY_SECTION_2\")\n\nprint(my_section_1)\nprint(my_section_2)\n```\n\n```py3\nDEFAULT_EXAMPLE(option1=20, option2=[10, 20], option3={'default_key': 'default_value'}, option4=5.2)\nDEFAULT_EXAMPLE(option1=20, option2=[('value2a', 'value2b'), ('value2c', 'value2b'), ('value2c', 'value2d')], option3={'key': 'value'}, option4=None)\n```\n\nCheck `example` directory for more examples.\n\n## Defaults\n\n- `configparser` includes sensible defaults options which allows you to declare a `[DEFAULT]` section in the config file for fallback values.\n- `typed_configparser` goes a step further and allows you to set a final (last) level of defaults at dataclass level.\n\n# License\n\n[MIT License](./LICENSE)\n\n# Contribution\n\nIf you are interested in contributing to typed_configparser, please take a look at the [contributing guidelines](./CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajatkj%2Ftyped_configparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajatkj%2Ftyped_configparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajatkj%2Ftyped_configparser/lists"}