python / python/peps

Decouple and unify PEP header processing for rendering, PEP 0, JSON, RSS and linting

Open
#2,587 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

infra
Dominant language
reStructuredText
Stars
5k
Forks
1.8k
Avg merge
2d 4h
Merged PRs (30d)
25

Description

As a followup to #2584 and #2585 and as I've already been thinking about lately and discussed with @JelleZijlstra and @warsaw at PyCon, right now we parse the headers three different places with three different sets of logic:

  • pep_zero_generator.parser for PEP 0, the JSON and the RSS with some additional sub-parsing in those callers
  • pep_processor.transforms.header_transform for the PEP rendering
  • The .pre-commit-config.yaml pygrep hooks for linting),

Instead, we should just use the structured format I suggest in #2584 (with the parsing presumably in the PEP class) for all of them (starting with PEP rendering initially), for several reasons:

  • Simpler, more DRY, reliable and maintainable in the long run
  • Easier to add new headers in one central place, as in #2572
  • Enables simplifying/loosening the allowed input syntax for authors without fear of breaking anything
  • Simplifies adding requested features in the various outputs (e.g. :abbr: from #2514 )
  • Decouples the header format from reST/Sphinx and ensures the format-independence @AA-Turner originally wanted in #2358
  • Avoids cryptic regexes for linting (as @hugovk requested on #2484)

Of course, we should decide on and implement the structured format proposed in #2584 first, as it is a perquisite for this (alongside the changes in #2585 and #2579 needing to be merged before work on this begins), but I've opened this to keep track of it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review #2584, #2585, and #2579 first, since this work depends on them. Then compare pep_zero_generator.parser, pep_processor.transforms.header_transform, and the .pre-commit-config.yaml pygrep hooks; done means one structured header format is used consistently for PEP rendering, PEP 0, JSON, RSS, and linting.

Written by the indexing model from the issue text.

Assessment

Domain
documentation, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.