Lint: Validate PEP fields against PEP 12 #1890
Merged
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.
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:
Created
regex to also checkPost-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 nowDiscussions-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 outThis caught a number of minor issues, which I fixed:
2.6 / 3.0
instead of the standard2.6, 3.0
, 3000 instead of 3.0, N/A/blank on non-standards-track PEPs that are not required to have them, etc.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.