-
-
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
Changes from 6 commits
d76aca9
6f3b39b
6a4866d
8b0379a
3d2f0f7
5b0381b
3eb6753
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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 |
| 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,24 @@ local_scheme = "no-local-version" | |||||||
|
|
||||||||
| [tool.black] | ||||||||
|
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. 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 :)
Suggested change
Collaborator
Author
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 don't mind too much. This is the only change it would make: diff --git a/sphinxlint/cli.py b/sphinxlint/cli.py
index c0a5638..0cab6d4 100644
--- a/sphinxlint/cli.py
+++ b/sphinxlint/cli.py
@@ -76,11 +76,7 @@ def parse_args(argv=None):
help="verbose (print all checked file names)",
)
parser.add_argument(
- "-i",
- "--ignore",
- action="append",
- help="ignore subdir or file path",
- default=[],
+ "-i", "--ignore", action="append", help="ignore subdir or file path", default=[]
)
parser.add_argument(
"-d",I can see there could be value keeping it, if we wanted to make sure each
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'd personally vote for my suggestion above^, but no strong opinion either way. Feel free to merge! |
||||||||
|
|
||||||||
| [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
|
||||||||
| ] | ||||||||
|
|
||||||||
| [tool.pylint.variables] | ||||||||
| callbacks = ["check_"] | ||||||||
| 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 | ||
|
|
||
|
|
||
| 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 | ||
| =================== | ||
|
|
||
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.
In general I prefer to use
pre-commit.ci, but I know that this is easier to setup in that it doesn't require giving thepre-commit.cibot permissions on this repo :)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.
why-not-both.gif? :)People who fork this repo might enable the CI for testing for their fork, and find lint issues sooner. (And not every lint issue is auto-fixable when a PR is opened.)
Fail fast.
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.
no reason except CO2 emissions :)