--- id: flexparser version: "0.4" license: BSD-3-Clause license_treatment: permissive maintenance: dormant --- # flexparser — Parsing made fun ... using typing. License: permissive · Maintenance: dormant · Downloads: 5.7M/mo ## What it is and what it does flexparser is a parser framework that lets you define custom statement types as frozen dataclasses with a `from_string` classmethod. Instead of writing a traditional recursive-descent or grammar-based parser, you write one class per statement type and the framework handles iteration, error collection, and file I/O. Each parsed statement is automatically annotated with line and column positions, raw text, and a content hash. The framework distinguishes between statements the parser doesn't recognize (returns None), valid statements, and parsing errors (subclasses of ParsingError). It also supports grouping statements into blocks with begin/end markers. The result is a sequence of typed objects you can iterate over, making downstream processing type-safe and straightforward. It depends only on typing-extensions and requires Python 3.9 or later. Use it for: - Parse domain-specific languages or configuration formats where each line type maps to a distinct dataclass. - Build error-tolerant parsers that collect all parsing failures and continue, reporting them at the end. - Parse structured text files (logs, reports, DSLs) where you want position tracking and type safety without writing a grammar. - Validate and extract data from line-oriented text where different line patterns need different handling logic. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. flexparser lets you build parsers by writing dataclasses with a `from_string` method, automatically handling file parsing, error reporting, and structured output with type safety. Yes, if you need a lightweight, type-safe parser for line-oriented text and don't require active maintenance. The low dependency footprint and permissive license make it a reasonable choice for small-to-medium parsing tasks. The dormant status means no new features or bug fixes are likely, so evaluate whether the current API and behavior meet your needs before committing. ## Install pip install flexparser uv add flexparser poetry add flexparser ## Installing flexparser Before you install: Low friction: pure Python wheel with only typing-extensions as a runtime dependency. Maintenance is dormant—last release was 2024-11-07 and last commit 2024-11-09, with no recent activity; the package is stable but not actively developed. License in practice: BSD-3-Clause is permissive and imposes no significant restrictions on use or redistribution, making it suitable for most commercial and open-source projects. Quickstart: pip install flexparser from dataclasses import dataclass import flexparser as fp @dataclass(frozen=True) class Assignment(fp.ParsedStatement): lhs: str rhs: str @classmethod def from_string(cls, s): if "<-" not in s: return None lhs, rhs = s.split("<-") return cls(lhs.strip(), rhs.strip()) parsed = fp.parse("file.txt", Assignment) for statement in parsed.iter_statements(): print(statement) Verify before relying: - Whether the package handles nested or recursive block structures beyond the single-level Block example shown. - Performance characteristics when parsing large files or deeply nested structures. - Whether custom error recovery or partial parsing is supported beyond returning None or a ParsingError. ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 5.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags dataclass-based parser, typed parsing framework, line-by-line file parser, parsing with type hints, structured text parsing, error-aware parser builder, statement parsing library, dataclass-parser, type-safe-parsing [View on SkillFed](https://skillfed.io/packages/flexparser) · [View on PyPI](https://pypi.org/project/flexparser/)