Registry / serialization / flexparser

flexparser

JSON →
library0.4pypypi✓ verified 30d ago

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.

pip install flexparser
INSTALL
IMPORT
SIG · FLEXPARSER
F
flexparser
serializationpythonv0.4
Install
1.6s avg
Import
167ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.170s · 18.3MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.164s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
✓ from flexparser import Parser
✗ from flexparser import parse_string

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`.

from flexparser import parse_string from typing import Dict, List, Union, Tuple # Define the target structure using type hints. # Flexparser will use these annotations at runtime to understand # how to parse the input string. def parse_config_data(data_str: str) -> Dict[str, Union[str, int, float, bool, List[str], Tuple[int, int]]]: """ Parses a string into a dictionary based on the return type hints. The function body itself is not executed for parsing; only its annotations are used by flexparser. """ pass config_string = """ name: Alice age: 30 city: New York tags: python, parsing location: (10, 20) is_active: true score: 98.5 """ # Parse the string using the return annotation of 'parse_config_data' parsed_data = parse_string(config_string, target_type=parse_config_data.__annotations__['return']) print("Parsed Data:", parsed_data) print("Type of name:", type(parsed_data.get('name'))) print("Type of age:", type(parsed_data.get('age'))) print("Type of tags:", type(parsed_data.get('tags'))) print("Type of location:", type(parsed_data.get('location'))) print("Type of is_active:", type(parsed_data.get('is_active')))
Debug
Known issues
breakingAs 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.
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`).
affects: <1.0.0
gotchaFlexparser 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.
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.
affects: all
gotchaError messages for malformed input might sometimes be generic or not pinpoint the exact line/token causing the issue, making debugging complex parsing failures challenging.
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.
affects: all
Upgrade
Version history
0.4latest on PyPI · released Nov 7, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
flexparser — pip install flexparser · libregistry