Skip to content
Merged

ruff #108

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ concurrency:
jobs:
test:
name: test on CPython ${{ matrix.py }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py:
- "3.12.0-beta.1"
- "3.12.0-beta.2"
- "3.11"
- "3.10"
- 3.9
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

check:
name: tox env ${{ matrix.tox_env }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
release:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/sphinx-argparse-cli
Expand Down
8 changes: 0 additions & 8 deletions .markdownlint.yaml

This file was deleted.

63 changes: 9 additions & 54 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,33 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--safe]
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.3]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.0"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.12.0"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.3.23
- flake8-comprehensions==3.12
- flake8-pytest-style==1.7.2
- flake8-spellcheck==0.28
- flake8-unused-arguments==0.0.13
- flake8-noqa==1.3.1
- pep8-naming==0.13.3
- flake8-pyproject==1.2.3
- id: pyproject-fmt
additional_dependencies: ["tox>=4.6.1"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
rev: "v3.0.0-alpha.9-for-vscode"
hooks:
- id: prettier
additional_dependencies:
- [email protected]
- "@prettier/[email protected]"
args: ["--print-width=120", "--prose-wrap=always"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.272"
hooks:
- id: markdownlint
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.9.2"
hooks:
- id: pyproject-fmt
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ to avoid reference label clash when the same anchors are generated in multiple d

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

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

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

- to refer to the optional arguments group use `` :ref:`cli:tox-optional-arguments` ``,
- to refer to the run subcommand use `` :ref:`cli:tox-run` ``,
- to refer to flag `--magic` of the `run` sub-command use `` :ref:`cli:tox-run---magic` ``.
- to refer to the optional arguments group use ``:ref:`cli:tox-optional-arguments` ``,
- to refer to the run subcommand use ``:ref:`cli:tox-run` ``,
- to refer to flag `--magic` of the `run` sub-command use ``:ref:`cli:tox-run---magic` ``.
55 changes: 33 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.3",
"hatchling>=1.14",
"hatchling>=1.18",
]

[project]
Expand All @@ -14,7 +14,7 @@ keywords = [
"sphinx",
]
license = "MIT"
maintainers = [{ name = "Bernat Gabor", email = "[email protected]" }]
maintainers = [{ name = "Bernat Gabor", email = "[email protected]" }] # noqa: E999
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -24,8 +24,12 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"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 :: Implementation :: CPython",
"Topic :: Documentation",
"Topic :: Documentation :: Sphinx",
Expand All @@ -34,12 +38,12 @@ dynamic = [
"version",
]
dependencies = [
"sphinx>=6.1.3",
"sphinx>=7.0.1",
]
optional-dependencies.test = [
"covdefaults>=2.3",
"pytest>=7.3.1",
"pytest-cov>=4",
"pytest>=7.3.2",
"pytest-cov>=4.1",
]
urls.Documentation = "https://github.com/tox-dev/sphinx-argparse-cli#sphinx-argparse-cli"
urls.Homepage = "https://github.com/tox-dev/sphinx-argparse-cli"
Expand All @@ -54,20 +58,30 @@ version.source = "vcs"
[tool.black]
line-length = 120

[tool.isort]
known_first_party = ["sphinx_argparse_cli", "tests"]
profile = "black"
line_length = 120

[tool.flake8]
max-complexity = 22
max-line-length = 120
unused-arguments-ignore-abstract-functions = true
noqa-require-code = true
dictionaries = ["en_US", "python", "technical", "django"]
[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py38"
isort = {known-first-party = ["sphinx_argparse_cli"], required-imports = ["from __future__ import annotations"]}
ignore = [
"E203", # whitespace before ':'
"W503", # line break before binary operator
"ANN101", # no typoe annotation for self
"ANN401", # allow Any as type annotation
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"S104", # Possible binding to all interface
]
[tool.ruff.per-file-ignores]
"tests/**/*.py" = [
"S101", # asserts allowed in tests...
"FBT", # don"t care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"D", # don"t care about documentation in tests
"S603", # `subprocess` call: check for execution of untrusted input
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
]
"roots/**/*.py" = [
"INP001", # no namespace
"D", # no docs
]

[tool.coverage]
Expand All @@ -84,6 +98,3 @@ run.relative_files = true
python_version = "3.11"
show_error_codes = true
strict = true

[tool.pep8]
max-line-length = "120"
2 changes: 1 addition & 1 deletion roots/test-default-handling/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def main() -> None:
parser = ArgumentParser(prog="foo", add_help=False)
parser.add_argument("x", default=1, help="arg (default: True)")
args = parser.parse_args()
print(args)
print(args) # noqa: T201
2 changes: 1 addition & 1 deletion roots/test-hook-fail/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

def main() -> None:
parser = ArgumentParser(prog="foo", add_help=False)
print(parser)
print(parser) # noqa: T201
2 changes: 1 addition & 1 deletion roots/test-hook/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
def main() -> None:
parser = ArgumentParser(prog="foo", add_help=False)
args = parser.parse_args()
print(args)
print(args) # noqa: T201
12 changes: 9 additions & 3 deletions src/sphinx_argparse_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
"""Sphinx generator for argparse."""
from __future__ import annotations

from sphinx.application import Sphinx
from typing import TYPE_CHECKING

from .version import __version__

if TYPE_CHECKING:
from sphinx.application import Sphinx


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

from ._logic import SphinxArgparseCli

app.add_directive(SphinxArgparseCli.name, SphinxArgparseCli)
app.add_config_value("sphinx_argparse_cli_prefix_document", False, "env")
app.add_config_value("sphinx_argparse_cli_prefix_document", False, "env") # noqa: FBT003


__all__ = ("__version__",)
__all__ = [
"__version__",
]
Loading