Repository navigation
feat(python): add the python port of trackparse - #3
Merged
Merged
Conversation
R0.6 used Unicode Alphabetic, which Python's str.isalpha() cannot match (it excludes Nl and combining marks). Only R6.7 uses the test. Two fixtures pin the new definition.
A non-array knownArtists or keyword list (and non-object keyword maps) threw a TypeError, breaking R0.8. Only arrays of strings and plain objects' string values are used now, matching the Python port.
R8.4 rescanned the whole title for every stripped phrase, so repeated trailing junk was quadratic (40k code points took ~1.7 s). Word spans are now computed once and walked backwards.
PyPI package trackparse for Python 3.9+, zero dependencies, frozen dataclasses with to_dict() giving the spec JSON. Passes all 11,891 shared fixtures with output byte-identical to JS (scripts/compare-ports.mjs). Adds python.yml CI (3.9-3.14 + wheel conformance), python joins the linked release group, and release.yml publishes to PyPI via trusted publishing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Python port: the PyPI package
trackparsefor Python 3.9+, with zero dependencies. It passes all 11,891 shared fixtures, and its output is byte-identical to JS:scripts/compare-ports.mjsdiffs the full JSON of every fixture case across both ports and finds 0 differences.Commits (please use Rebase and merge, so release-please lists each one in the changelog)
feat(spec): R0.6 now defines a letter as Unicode general category L (JS\p{L}, Pythonisalpha()). Two new fixtures pin the change.fix(js): a malformedknownArtistsor keyword option threw a TypeError, which breaks R0.8. Found in code review; Python already handled it.perf(js): trailing junk stripping (R8.4) was quadratic. A 40k-character input took about 1.7 s and now takes about 35 ms. Both ports have a regression test.feat(python): the port itself (python/), CI, release wiring and docs.Python package
src/trackparse/mirrorsjs/srcmodule for module, with the same rule-ID comments. Results are frozen dataclasses with snake_case attributes, andto_dict()/from_dict()convert to and from the spec JSON.parse,parse_artists,format_track,normalize,all_artists,create_parser,SPEC_VERSION,__version__.CI and release
python.yml: ruff,mypy --strictand pytest on Python 3.9–3.14. A build job installs the wheel into a clean venv and runsconformance.py --strictagainst it.spec.yml: checks that the js, spec and python versions all match.release.ymlhas a newpublish-pypijob that uses trusted publishing (environmentpypi).python/README.md(the PyPI page),.github/release-notes/0.2.0.md.Before merging the release PR
The PyPI pending publisher must exist: project
trackparse, owner4matic, repotrackparse, workflowrelease.yml, environmentpypi.Test plan
mypy --strict, gen_data check; wheel conformance at 100%compare-ports.mjs: 0 differences across all 11,891 casesgen:check