skillfed

flexparser

Parsing made fun ... using typing.

flexparser v0.4 5.7M downloads/30d#2,046 on PyPI5
Permissive license BSD-3-Clause DORMANT released

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 on this page — 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

flexparser on PyPI

pip

pip install flexparser

uv

uv add flexparser

poetry

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 the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — typing-extensions
Maintenance dormant — 645 days since the last release
Last repo commit
First released
Downloads 5,716,000/month — #2,046 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: flexparser-0.4-py3-none-any.whl

Keywords: parser, code, parsing, source

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: System :: FilesystemsTopic :: Utilities

Tags

dataclass-based parsertyped parsing frameworkline-by-line file parserparsing with type hintsstructured text parsingerror-aware parser builderstatement parsing library
dataclass-parsertype-safe-parsing

More Libraries packages