Skip to content

Settle and document the public Python API before 1.0 #3577

Description

@ESultanik

Summary

polyfile/__init__.py exports a public Python API — Matcher, Parser, PARSERS,
register_parser, Submatch, Match, InvalidMatch — but nothing states what a caller may rely
on. There is no py.typed marker, no documented contract, and no deprecation policy. Before
declaring 1.0, decide what that surface is and write it down.

This is an entry criterion for the v1.0.0 milestone, not a defect.

Why now

The v0.6.0 cycle changed that surface repeatedly, which is the evidence that it is not yet settled:

A 1.0 version number promises that breaking changes wait for 2.0. That promise is only meaningful if
the surface it covers is defined.

What this needs

  1. Decide what is public. polyfile/__init__.py's exports are the current de facto answer, but
    Analyzer, MagicMatcher, MagicTest, FileStream and MatchContext are all reachable and
    used by the documented extension points. Either bring them in deliberately or state that they are
    internal.
  2. Write the contract. docs/extending_polyfile.md exists and should carry it: what a custom
    matcher and a custom parser must implement, what they may rely on, and what the library
    guarantees across minor versions. The corrected examples from Documentation describes a PDF parser and a registration API that were both replaced #3467 are the starting point.
  3. Add a py.typed marker so type checkers see the annotations the package already carries, and
    decide whether the annotated signatures are part of the contract.
  4. Settle Implement all-offsets scanning for embedded file detection #3532 first, or state that it is out. Implementing all-offsets scanning would change
    Matcher's behavior and possibly its constructor. Deciding that after 1.0 means either breaking
    the promise or shipping it awkwardly.
  5. State a deprecation policy. One minor release with a warning is the usual shape; any policy
    is better than none.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions