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

Add Sphinx Lint to pre-commit #1786

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

Add Sphinx Lint to pre-commit #1786

wants to merge 6 commits into from

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Jan 14, 2025

Plus add a few other handy linters and bump GitHub Actions.


📚 Documentation preview 📚: https://python-packaging-user-guide--1786.org.readthedocs.build/en/1786/

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

It'd be nice to split this so it's obvious what triggered formatting..

@hugovk
Copy link
Contributor Author

hugovk commented Jan 14, 2025

Sure, how's this?

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
Copy link

Choose a reason for hiding this comment

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

This is already mentioned below.

Copy link

Choose a reason for hiding this comment

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

BTW, I also tried this check, and it was horrible, because it complained about every instance of single-backticked words in my .rst files. It's valid to use single backticks, it's just not code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've removed the duplicate.

Yep, it's valid, although it's pretty common people intend to write code but forget they're writing RST and not MD, and it shows as italics instead.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, also some projects explicitly define its role to be the same (https://github.com/pytest-dev/pytest/blob/517b006/doc/en/conf.py#L61C1-L61C25), confusing a casual contributor even more...

@@ -8,10 +8,11 @@ repos:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
Copy link
Member

Choose a reason for hiding this comment

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

What's the justification here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flagged by the check-hooks-apply hook. Shall I remove check-hooks-apply and re-add check-symlinks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flagged by the check-hooks-apply hook:

Check hooks apply to the repository......................................Failed
- hook id: check-hooks-apply
- exit code: 1

check-symlinks does not apply to this repository

Shall I remove check-hooks-apply and re-add check-symlinks?

Copy link
Member

Choose a reason for hiding this comment

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

Honesty, not sure. I was just trying to understand how different bits of the PR might be related to the declared goal and each other...

Copy link
Member

Choose a reason for hiding this comment

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

Ned ended up not using this check: #1786 (comment). Perhaps, we shouldn't either.

@@ -8,10 +8,11 @@ repos:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-json
Copy link
Member

Choose a reason for hiding this comment

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

Could you add explanation somewhere why one check replaces the other instead of being additional?

Copy link

Choose a reason for hiding this comment

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

I'll take a guess based on what I saw: check-hooks-apply complains that check-symlinks doesn't apply if the repo has no symlinks.

Copy link
Member

Choose a reason for hiding this comment

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

Oh.. I wish that was more apparent.

Copy link
Member

Choose a reason for hiding this comment

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

Thinking about it... It's rather suboptimal: if we ever start having symlinks, they won't be checked after this patch because nobody will remember to re-add it.

Copy link

Choose a reason for hiding this comment

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

I agree. But perhaps it means we don't want check-hooks-apply.

Copy link

Choose a reason for hiding this comment

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

After trying it in coveragepy, I removed check-hooks-apply.

.pre-commit-config.yaml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants