-
-
Notifications
You must be signed in to change notification settings - Fork 24
Lint on GitHub Actions via pre-commit #104
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d76aca9
Format with Black via pre-commit
hugovk 6f3b39b
Lint with Ruff
hugovk 6a4866d
Add some handy pre-commit hooks
hugovk 8b0379a
Apply common format to pyproject.toml and validate
hugovk 3d2f0f7
Format tox.ini
hugovk 5b0381b
autoupdate_schedule: quarterly
hugovk 3eb6753
Ignore UP038: it makes code slower and more verbose
hugovk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Lint | ||
|
|
||
| on: [push, pull_request, workflow_dispatch] | ||
|
|
||
| env: | ||
| FORCE_COLOR: 1 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "3.x" | ||
| - uses: pre-commit/action@v3.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| repos: | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.1.6 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix, --exit-non-zero-on-fix] | ||
|
|
||
| - repo: https://github.com/psf/black-pre-commit-mirror | ||
| rev: 23.11.0 | ||
| hooks: | ||
| - id: black | ||
|
|
||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.5.0 | ||
| hooks: | ||
| - id: check-case-conflict | ||
| - id: check-merge-conflict | ||
| - id: check-toml | ||
| - id: check-yaml | ||
| - id: debug-statements | ||
| - id: end-of-file-fixer | ||
| exclude: tests/fixtures/xfail/missing-newline-at-end-of-file.rst | ||
| - id: trailing-whitespace | ||
| exclude: tests/fixtures/xfail/trailing-whitespaces.rst | ||
|
|
||
| - repo: https://github.com/tox-dev/pyproject-fmt | ||
| rev: 1.5.1 | ||
| hooks: | ||
| - id: pyproject-fmt | ||
| additional_dependencies: [tox] | ||
|
|
||
| - repo: https://github.com/abravalheri/validate-pyproject | ||
| rev: v0.15 | ||
| hooks: | ||
| - id: validate-pyproject | ||
|
|
||
| - repo: https://github.com/tox-dev/tox-ini-fmt | ||
| rev: 1.3.1 | ||
| hooks: | ||
| - id: tox-ini-fmt | ||
|
|
||
| - repo: meta | ||
| hooks: | ||
| - id: check-hooks-apply | ||
| - id: check-useless-excludes | ||
|
|
||
| ci: | ||
| autoupdate_schedule: quarterly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,31 +14,36 @@ authors = [ | |
| {name = "Georg Brandl", email = "georg@python.org"}, | ||
| {name = "Julien Palard", email = "julien@palard.fr"}, | ||
| ] | ||
| requires-python = ">= 3.8" | ||
| classifiers = [ | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Topic :: Documentation :: Sphinx", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: Python Software Foundation License", | ||
| "Natural Language :: English", | ||
| "Programming Language :: Python :: 3", | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: Python Software Foundation License", | ||
| "Natural Language :: English", | ||
| "Programming Language :: Python :: 3 :: Only", | ||
| "Programming Language :: Python :: 3.8", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Topic :: Documentation :: Sphinx", | ||
| ] | ||
| dynamic = [ | ||
| "version", | ||
| ] | ||
| requires-python = ">= 3.8" | ||
| dependencies = [ | ||
| "regex", | ||
| "polib", | ||
| "polib", | ||
| "regex", | ||
| ] | ||
| dynamic = ["version"] | ||
|
|
||
|
|
||
| [project.optional-dependencies] | ||
| tests = [ | ||
| "pytest", | ||
| "pytest-cov", | ||
| ] | ||
| [project.urls] | ||
| Repository = "https://github.com/sphinx-contrib/sphinx-lint" | ||
| Changelog = "https://github.com/sphinx-contrib/sphinx-lint/releases" | ||
|
|
||
| Repository = "https://github.com/sphinx-contrib/sphinx-lint" | ||
| [project.scripts] | ||
| sphinx-lint = "sphinxlint.cli:main" | ||
|
|
||
|
|
@@ -50,5 +55,25 @@ local_scheme = "no-local-version" | |
|
|
||
| [tool.black] | ||
|
|
||
| [tool.ruff] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a fan of autofixes, so we could add |
||
| select = [ | ||
| "E", # pycodestyle errors | ||
| "F", # pyflakes errors | ||
| "I", # isort | ||
| "ISC", # flake8-implicit-str-concat | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "PGH", # pygrep-hooks | ||
| "RUF100", # unused noqa (yesqa) | ||
| "UP", # pyupgrade | ||
| "W", # pycodestyle warnings | ||
| "YTT", # flake8-2020 | ||
| ] | ||
| extend-ignore = [ | ||
| "E203", # Whitespace before ':' | ||
| "E221", # Multiple spaces before operator | ||
| "E226", # Missing whitespace around arithmetic operator | ||
| "E241", # Multiple spaces after ',' | ||
hugovk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "UP038", # makes code slower and more verbose | ||
| ] | ||
|
|
||
| [tool.pylint.variables] | ||
| callbacks = ["check_"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| from random import choice | ||
| import re | ||
| from random import choice | ||
|
|
||
| from sphinxlint.cli import main | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| from sphinxlint.utils import hide_non_rst_blocks | ||
|
|
||
|
|
||
| LITERAL = r""" | ||
| Hide non-RST Blocks | ||
| =================== | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly we could enable this setting for black. I don't much like the magic trailing comma, and I think most of the current black maintainers don't really like it much either. But I also don't care that much, if you disagree :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind too much. This is the only change it would make:
I can see there could be value keeping it, if we wanted to make sure each
parser.add_argumentblock had each arg on its own line. 🤷There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally vote for my suggestion above^, but no strong opinion either way. Feel free to merge!