You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Both "Extending PolyFile" examples in CLAUDE.md were non-functional, and the register_parser
example documented the wrong shape entirely — it decorated a class, where register_parser wraps
its argument in a function wrapper (Documentation describes a PDF parser and a registration API that were both replaced #3467). Anyone following the guide got TypeError: MyParser() takes no arguments.
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
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.
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.
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.
State a deprecation policy. One minor release with a warning is the usual shape; any policy
is better than none.
Summary
polyfile/__init__.pyexports a public Python API —Matcher,Parser,PARSERS,register_parser,Submatch,Match,InvalidMatch— but nothing states what a caller may relyon. There is no
py.typedmarker, no documented contract, and no deprecation policy. Beforedeclaring 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:
try_all_offsetswas removed fromMatcher.__init__andAnalyzer.__init__(try_all_offsets is accepted and ignored, and the CLI flag for it is commented out #3465). It had beenaccepted and ignored since it was introduced.
Matcher.matchchanged behavior substantially for an already-open stream (Matcher.match() returns almost no structure when given an open stream instead of a path #3463): it previouslyreturned 1 match where a path returned 51.
FileStream.__init__'slengthparameter had two contradictory meanings depending on whichbranch ran (Count a FileStream's length from its start in both branches #3561). One was chosen and documented; nothing had recorded which was intended.
CLAUDE.mdwere non-functional, and theregister_parserexample documented the wrong shape entirely — it decorated a class, where
register_parserwrapsits argument in a function wrapper (Documentation describes a PDF parser and a registration API that were both replaced #3467). Anyone following the guide got
TypeError: MyParser() takes no arguments.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
polyfile/__init__.py's exports are the current de facto answer, butAnalyzer,MagicMatcher,MagicTest,FileStreamandMatchContextare all reachable andused by the documented extension points. Either bring them in deliberately or state that they are
internal.
docs/extending_polyfile.mdexists and should carry it: what a custommatcher 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.
py.typedmarker so type checkers see the annotations the package already carries, anddecide whether the annotated signatures are part of the contract.
Matcher's behavior and possibly its constructor. Deciding that after 1.0 means either breakingthe promise or shipping it awkwardly.
is better than none.
Related
Matcher