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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pep-lint.py #3275

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Add pep-lint.py #3275

wants to merge 11 commits into from

Conversation

AA-Turner
Copy link
Member

@AA-Turner AA-Turner commented Aug 5, 2023

pep-lint represents all of the custom PEP lints in .pre-commit-config.yaml, converted into a single Python file. This is for (hopefully) easier maintenance, as I find it quite hard to decipher the regular expressions in .pre-commit-config.yaml, especially as they work on negative matching.

I haven't changed .pre-commit-config.yaml for now, but when we are confident in pep-lint, I would suggest removing the custom PEP rules such that there is a single-source of truth.

A


馃摎 Documentation preview 馃摎: https://pep-previews--3275.org.readthedocs.build/

@Rosuav
Copy link
Contributor

Rosuav commented Aug 6, 2023

LGTM. From my testing, it appears that this may place a minimum Python version of 3.9 on anyone who's going to edit PEPs; I think that's not unreasonable. Definitely in favour of doing these sorts of checks in a well-laid-out Python script, there are quite a few checks to be done.

@AA-Turner
Copy link
Member Author

minimum Python version of 3.9

Yep, I used str.removeprefix, which was added in 3.9. I could relax this, but we only test with 3.9+, so I thought it was reasonable to use the newer features.

A

@Rosuav
Copy link
Contributor

Rosuav commented Aug 6, 2023

minimum Python version of 3.9

Yep, I used str.removeprefix, which was added in 3.9. I could relax this, but we only test with 3.9+, so I thought it was reasonable to use the newer features.

A

Yep. Systems that don't have Python 3.9 include Debian Old-Old-Stable aka "Buster" and Ubuntu 20.04LTS "Focal", so I think it's perfectly reasonable to require it. There'll certainly be some servers out there that are on older Pythons, but editing PEPs is an interactive thing and I don't see a problem here.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I'd been thinking the same thing :)

We can make this a pre-commit hook too: https://pre-commit.com/#new-hooks (can be a follow-up).

It'd be really good to have some unit tests, so we can easily test what's valid and invalid. (Some type hints would be nice but not essential.)

Not tested yet, here's a few suggestions.

pep-lint.py Outdated Show resolved Hide resolved
pep-0499.txt Show resolved Hide resolved
pep-lint.py Show resolved Hide resolved
pep-lint.py Show resolved Hide resolved
pep-lint.py Show resolved Hide resolved
pep-lint.py Outdated Show resolved Hide resolved
pep-lint.py Outdated Show resolved Hide resolved
pep-lint.py Outdated Show resolved Hide resolved
pep-lint.py Outdated Show resolved Hide resolved
pep-lint.py Outdated Show resolved Hide resolved
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.

None yet

4 participants