Skip to content

Commit 76889c6

Browse files
authored
ruff (#108)
1 parent 538a2ba commit 76889c6

File tree

15 files changed

+130
-168
lines changed

15 files changed

+130
-168
lines changed

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ concurrency:
1313
jobs:
1414
test:
1515
name: test on CPython ${{ matrix.py }}
16-
runs-on: ubuntu-22.04
16+
runs-on: ubuntu-latest
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
py:
21-
- "3.12.0-beta.1"
21+
- "3.12.0-beta.2"
2222
- "3.11"
2323
- "3.10"
2424
- 3.9
@@ -54,7 +54,7 @@ jobs:
5454

5555
check:
5656
name: tox env ${{ matrix.tox_env }}
57-
runs-on: ubuntu-22.04
57+
runs-on: ubuntu-latest
5858
strategy:
5959
fail-fast: false
6060
matrix:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
release:
8-
runs-on: ubuntu-22.04
8+
runs-on: ubuntu-latest
99
environment:
1010
name: release
1111
url: https://pypi.org/p/sphinx-argparse-cli

.markdownlint.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,33 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.4.0
44
hooks:
5-
- id: check-ast
6-
- id: check-builtin-literals
7-
- id: check-docstring-first
8-
- id: check-merge-conflict
9-
- id: check-yaml
10-
- id: check-toml
11-
- id: debug-statements
125
- id: end-of-file-fixer
136
- id: trailing-whitespace
14-
- repo: https://github.com/asottile/add-trailing-comma
15-
rev: v2.4.0
16-
hooks:
17-
- id: add-trailing-comma
18-
args: [--py36-plus]
19-
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.3.1
21-
hooks:
22-
- id: pyupgrade
23-
args: ["--py38-plus"]
24-
- repo: https://github.com/PyCQA/isort
25-
rev: 5.12.0
26-
hooks:
27-
- id: isort
287
- repo: https://github.com/psf/black
298
rev: 23.3.0
309
hooks:
3110
- id: black
32-
args: [--safe]
33-
- repo: https://github.com/asottile/blacken-docs
34-
rev: 1.13.0
35-
hooks:
36-
- id: blacken-docs
37-
additional_dependencies: [black==23.3]
38-
- repo: https://github.com/pre-commit/pygrep-hooks
39-
rev: v1.10.0
40-
hooks:
41-
- id: rst-backticks
4211
- repo: https://github.com/tox-dev/tox-ini-fmt
4312
rev: "1.3.0"
4413
hooks:
4514
- id: tox-ini-fmt
4615
args: ["-p", "fix"]
47-
- repo: https://github.com/PyCQA/flake8
48-
rev: 6.0.0
16+
- repo: https://github.com/tox-dev/pyproject-fmt
17+
rev: "0.12.0"
4918
hooks:
50-
- id: flake8
51-
additional_dependencies:
52-
- flake8-bugbear==23.3.23
53-
- flake8-comprehensions==3.12
54-
- flake8-pytest-style==1.7.2
55-
- flake8-spellcheck==0.28
56-
- flake8-unused-arguments==0.0.13
57-
- flake8-noqa==1.3.1
58-
- pep8-naming==0.13.3
59-
- flake8-pyproject==1.2.3
19+
- id: pyproject-fmt
20+
additional_dependencies: ["tox>=4.6.1"]
6021
- repo: https://github.com/pre-commit/mirrors-prettier
61-
rev: "v2.7.1"
22+
rev: "v3.0.0-alpha.9-for-vscode"
6223
hooks:
6324
- id: prettier
64-
additional_dependencies:
65-
66-
- "@prettier/[email protected]"
6725
args: ["--print-width=120", "--prose-wrap=always"]
68-
- repo: https://github.com/igorshubovych/markdownlint-cli
69-
rev: v0.33.0
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: "v0.0.272"
7028
hooks:
71-
- id: markdownlint
29+
- id: ruff
30+
args: [--fix, --exit-non-zero-on-fix]
7231
- repo: meta
7332
hooks:
7433
- id: check-hooks-apply
7534
- id: check-useless-excludes
76-
- repo: https://github.com/tox-dev/pyproject-fmt
77-
rev: "0.9.2"
78-
hooks:
79-
- id: pyproject-fmt

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ to avoid reference label clash when the same anchors are generated in multiple d
7272

7373
For example in case of a `tox` command, and `sphinx_argparse_cli_prefix_document=False` (default):
7474

75-
- to refer to the optional arguments group use `` :ref:`tox-optional-arguments` ``,
76-
- to refer to the run subcommand use `` :ref:`tox-run` ``,
77-
- to refer to flag `--magic` of the `run` sub-command use `` :ref:`tox-run---magic` ``.
75+
- to refer to the optional arguments group use ``:ref:`tox-optional-arguments` ``,
76+
- to refer to the run subcommand use ``:ref:`tox-run` ``,
77+
- to refer to flag `--magic` of the `run` sub-command use ``:ref:`tox-run---magic` ``.
7878

7979
For example in case of a `tox` command, and `sphinx_argparse_cli_prefix_document=True`, and the current document name
8080
being `cli`:
8181

82-
- to refer to the optional arguments group use `` :ref:`cli:tox-optional-arguments` ``,
83-
- to refer to the run subcommand use `` :ref:`cli:tox-run` ``,
84-
- to refer to flag `--magic` of the `run` sub-command use `` :ref:`cli:tox-run---magic` ``.
82+
- to refer to the optional arguments group use ``:ref:`cli:tox-optional-arguments` ``,
83+
- to refer to the run subcommand use ``:ref:`cli:tox-run` ``,
84+
- to refer to flag `--magic` of the `run` sub-command use ``:ref:`cli:tox-run---magic` ``.

pyproject.toml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.3",
5-
"hatchling>=1.14",
5+
"hatchling>=1.18",
66
]
77

88
[project]
@@ -14,7 +14,7 @@ keywords = [
1414
"sphinx",
1515
]
1616
license = "MIT"
17-
maintainers = [{ name = "Bernat Gabor", email = "[email protected]" }]
17+
maintainers = [{ name = "Bernat Gabor", email = "[email protected]" }] # noqa: E999
1818
requires-python = ">=3.8"
1919
classifiers = [
2020
"Development Status :: 5 - Production/Stable",
@@ -24,8 +24,12 @@ classifiers = [
2424
"Intended Audience :: Developers",
2525
"License :: OSI Approved :: MIT License",
2626
"Operating System :: OS Independent",
27-
"Programming Language :: Python :: 3",
2827
"Programming Language :: Python :: 3 :: Only",
28+
"Programming Language :: Python :: 3.8",
29+
"Programming Language :: Python :: 3.9",
30+
"Programming Language :: Python :: 3.10",
31+
"Programming Language :: Python :: 3.11",
32+
"Programming Language :: Python :: 3.12",
2933
"Programming Language :: Python :: Implementation :: CPython",
3034
"Topic :: Documentation",
3135
"Topic :: Documentation :: Sphinx",
@@ -34,12 +38,12 @@ dynamic = [
3438
"version",
3539
]
3640
dependencies = [
37-
"sphinx>=6.1.3",
41+
"sphinx>=7.0.1",
3842
]
3943
optional-dependencies.test = [
4044
"covdefaults>=2.3",
41-
"pytest>=7.3.1",
42-
"pytest-cov>=4",
45+
"pytest>=7.3.2",
46+
"pytest-cov>=4.1",
4347
]
4448
urls.Documentation = "https://github.com/tox-dev/sphinx-argparse-cli#sphinx-argparse-cli"
4549
urls.Homepage = "https://github.com/tox-dev/sphinx-argparse-cli"
@@ -54,20 +58,30 @@ version.source = "vcs"
5458
[tool.black]
5559
line-length = 120
5660

57-
[tool.isort]
58-
known_first_party = ["sphinx_argparse_cli", "tests"]
59-
profile = "black"
60-
line_length = 120
61-
62-
[tool.flake8]
63-
max-complexity = 22
64-
max-line-length = 120
65-
unused-arguments-ignore-abstract-functions = true
66-
noqa-require-code = true
67-
dictionaries = ["en_US", "python", "technical", "django"]
61+
[tool.ruff]
62+
select = ["ALL"]
63+
line-length = 120
64+
target-version = "py38"
65+
isort = {known-first-party = ["sphinx_argparse_cli"], required-imports = ["from __future__ import annotations"]}
6866
ignore = [
69-
"E203", # whitespace before ':'
70-
"W503", # line break before binary operator
67+
"ANN101", # no typoe annotation for self
68+
"ANN401", # allow Any as type annotation
69+
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
70+
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
71+
"S104", # Possible binding to all interface
72+
]
73+
[tool.ruff.per-file-ignores]
74+
"tests/**/*.py" = [
75+
"S101", # asserts allowed in tests...
76+
"FBT", # don"t care about booleans as positional arguments in tests
77+
"INP001", # no implicit namespace
78+
"D", # don"t care about documentation in tests
79+
"S603", # `subprocess` call: check for execution of untrusted input
80+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
81+
]
82+
"roots/**/*.py" = [
83+
"INP001", # no namespace
84+
"D", # no docs
7185
]
7286

7387
[tool.coverage]
@@ -84,6 +98,3 @@ run.relative_files = true
8498
python_version = "3.11"
8599
show_error_codes = true
86100
strict = true
87-
88-
[tool.pep8]
89-
max-line-length = "120"

roots/test-default-handling/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def main() -> None:
77
parser = ArgumentParser(prog="foo", add_help=False)
88
parser.add_argument("x", default=1, help="arg (default: True)")
99
args = parser.parse_args()
10-
print(args)
10+
print(args) # noqa: T201

roots/test-hook-fail/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
def main() -> None:
77
parser = ArgumentParser(prog="foo", add_help=False)
8-
print(parser)
8+
print(parser) # noqa: T201

roots/test-hook/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
def main() -> None:
77
parser = ArgumentParser(prog="foo", add_help=False)
88
args = parser.parse_args()
9-
print(args)
9+
print(args) # noqa: T201

src/sphinx_argparse_cli/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1+
"""Sphinx generator for argparse."""
12
from __future__ import annotations
23

3-
from sphinx.application import Sphinx
4+
from typing import TYPE_CHECKING
45

56
from .version import __version__
67

8+
if TYPE_CHECKING:
9+
from sphinx.application import Sphinx
10+
711

812
def setup(app: Sphinx) -> None:
913
app.add_css_file("custom.css")
1014

1115
from ._logic import SphinxArgparseCli
1216

1317
app.add_directive(SphinxArgparseCli.name, SphinxArgparseCli)
14-
app.add_config_value("sphinx_argparse_cli_prefix_document", False, "env")
18+
app.add_config_value("sphinx_argparse_cli_prefix_document", False, "env") # noqa: FBT003
1519

1620

17-
__all__ = ("__version__",)
21+
__all__ = [
22+
"__version__",
23+
]

0 commit comments

Comments
 (0)