Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint: Validate PEP fields against PEP 12 #1890

Merged
merged 8 commits into from
Mar 23, 2021

Conversation

CAM-Gerlach
Copy link
Member

@CAM-Gerlach CAM-Gerlach commented Mar 23, 2021

Adds some more cheap Pygrep checks to conservatively validate the formally-specified PEP fields against PEP 12 (i.e. the required fields are present, and non-empty fields match any required format), with a few exceptions:

  • The Author/Sponsor/PEP-Delegate have a strictly-defined format in the spec, and I prototypes a regex to enforce it; however, due to numerous deviations in practice and the non-triviality of conforming them automatically, I don't attempt to enforce that here, and leave that to a future PR, if interest exists
  • Similarly, it was straightforward to modify the Created regex to also check Post-History, but given the number of deviations that would need to be corrected, the non-triviality of doing so programmatically, and the likely lesser interest in parsing the data, I didn't go through with that for now
  • The Discussions-To fields doesn't have a strictly defined format in PEP 12; in practice it conforms to either {URL}, {email_address}, or {name} <{URL or email_address> following the Author/etc field, but as this is complex to parse/validate and not formally specified, I left this out

This caught a number of minor issues, which I fixed:

  • A couple leading zeros on PEP numbers, as prohibited by PEP 12
  • Some isolated instances of Python-Version not following the specified X.Y(.Z) format: e.g. 2.6 / 3.0 instead of the standard 2.6, 3.0, 3000 instead of 3.0, N/A/blank on non-standards-track PEPs that are not required to have them, etc.
  • A URL missing HTTPS, and one with an errant space
  • A few rejected/differed/withdrawn PEPs that had out of date TBD or empty Resolved fields (though the validation allows this, so as to not break intentional use)
  • Some misc typos in fields

In some cases, some of the fields had extra information in parenthesis after the validated value; I allowed this in the regexes, and didn't modify or remove any such instances; nor did I remove any fields with non-empty values just to conform to the specification.

Running the full suite on the entire repo adds around ≈10 extra seconds to the lint job, but as this is still far faster than the build job, it makes no significant difference in practice.

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

Successfully merging this pull request may close these issues.

4 participants