{"id":2034,"library":"flexparser","title":"Flexparser for Typed Parsing","description":"Flexparser is a Python library that enables parsing of string-based data into complex Python objects using type hints. Inspired by Pydantic, it leverages `typing` module annotations to define target data structures. Currently at version 0.4, its release cadence is infrequent but maintained.","status":"active","version":"0.4","language":"python","source_language":"en","source_url":"https://github.com/hgrecco/flexparser","tags":["parsing","type hints","dataclasses","declarative","yaml-like","pydantic-inspired"],"install":[{"cmd":"pip install flexparser","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"wrong":"from flexparser import parse_string","symbol":"Parser","correct":"from flexparser import Parser"}],"quickstart":{"code":"from flexparser import parse_string\nfrom typing import Dict, List, Union, Tuple\n\n# Define the target structure using type hints.\n# Flexparser will use these annotations at runtime to understand\n# how to parse the input string.\ndef parse_config_data(data_str: str) -> Dict[str, Union[str, int, float, bool, List[str], Tuple[int, int]]]:\n    \"\"\"\n    Parses a string into a dictionary based on the return type hints.\n    The function body itself is not executed for parsing;\n    only its annotations are used by flexparser.\n    \"\"\"\n    pass\n\nconfig_string = \"\"\"\nname: Alice\nage: 30\ncity: New York\ntags: python, parsing\nlocation: (10, 20)\nis_active: true\nscore: 98.5\n\"\"\"\n\n# Parse the string using the return annotation of 'parse_config_data'\nparsed_data = parse_string(config_string, target_type=parse_config_data.__annotations__['return'])\n\nprint(\"Parsed Data:\", parsed_data)\nprint(\"Type of name:\", type(parsed_data.get('name')))\nprint(\"Type of age:\", type(parsed_data.get('age')))\nprint(\"Type of tags:\", type(parsed_data.get('tags')))\nprint(\"Type of location:\", type(parsed_data.get('location')))\nprint(\"Type of is_active:\", type(parsed_data.get('is_active')))","lang":"python","description":"This quickstart demonstrates how to use `flexparser.parse_string` to parse a YAML-like string into a Python dictionary, leveraging type hints for schema definition. The `target_type` argument tells `flexparser` what structure to expect, which it infers from the return annotation of `parse_config_data`."},"warnings":[{"fix":"Refer to the GitHub repository for the latest API documentation and examples. Pin exact minor versions in your `requirements.txt` to prevent unexpected breaks (e.g., `flexparser==0.4`).","message":"As a pre-1.0 library, `flexparser`'s API is subject to change without prior notice across minor versions. Features might be renamed, modified, or removed.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Stick to standard Python types (e.g., `str`, `int`, `float`, `bool`, `List`, `Dict`, `Tuple`, `Union`) for best compatibility. For custom types, consult the source code or experiment with simple examples first to understand current capabilities.","message":"Flexparser relies heavily on runtime type introspection for parsing. Complex or highly nested custom types, or advanced `typing` features (e.g., `TypedDict`, `NewType`) might require explicit parser registration or might not be fully supported without specific extensions.","severity":"gotcha","affected_versions":"all"},{"fix":"Test parsing with incremental complexity. Use smaller input snippets to isolate issues. For critical data, consider adding preliminary input validation before parsing to catch common structural errors earlier.","message":"Error messages for malformed input might sometimes be generic or not pinpoint the exact line/token causing the issue, making debugging complex parsing failures challenging.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.4':41 'annot':32 'base':16 'cadenc':44 'complex':19 'current':38 'data':17,36 'dataclass':52 'declar':53 'defin':34 'enabl':11 'flexpars':1,5 'hint':24,51 'infrequ':46 'inspir':25,59 'leverag':29 'librari':9 'like':56 'maintain':48 'modul':31 'object':21 'pars':4,12,49 'pydant':27,58 'pydantic-inspir':57 'python':8,20 'releas':43 'string':15 'string-bas':14 'structur':37 'target':35 'type':3,23,30,50 'use':22 'version':40 'yaml':55 'yaml-lik':54","created_at":"2026-04-09T18:40:41.618460+00:00","updated_at":"2026-04-16T15:09:16.269992+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/hgrecco/flexparser","docs":null,"changelog":null,"pypi":"https://pypi.org/project/flexparser/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-08-28","next_check":"2026-07-30","install_tag":null}}