Skip to content

Commit

Permalink
Add config
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Jun 14, 2023
1 parent b138c5c commit 1136d62
Show file tree
Hide file tree
Showing 166 changed files with 1,181 additions and 1,136 deletions.
12 changes: 0 additions & 12 deletions .markdownlint.yaml

This file was deleted.

70 changes: 9 additions & 61 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,32 @@ 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
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.272"
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]
exclude: "^(tests/demo_pkg_inline/build.py)$"
- id: pyupgrade
files: "^(tests/demo_pkg_inline/build.py)$"
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- 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.11.2"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.5.9
- 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"]
- 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:
- prettier@2.7.1
- "@prettier/plugin-xml@2.2"
args: ["--print-width=120", "--prose-wrap=always"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.34.0
hooks:
- id: markdownlint
- repo: local
hooks:
- id: changelogs-rst
name: changelog filenames
language: fail
entry: "changelog files must be named ####.(feature|bugfix|doc|removal|misc).rst"
exclude: ^docs/changelog/(\d+\.(feature|bugfix|doc|removal|misc).rst|template.jinja2)
files: ^docs/changelog/
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
29 changes: 15 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
from importlib.machinery import SourceFileLoader
from pathlib import Path
from subprocess import check_output
from typing import Any
from typing import TYPE_CHECKING, Any

from docutils.nodes import Element, reference
from sphinx.addnodes import pending_xref
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.domains.python import PythonDomain
from sphinx.environment import BuildEnvironment
from sphinx.ext.autodoc import Options
from sphinx.ext.extlinks import ExternalLinksChecker

from tox import __version__

if TYPE_CHECKING:
from docutils.nodes import Element, reference
from sphinx.addnodes import pending_xref
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.environment import BuildEnvironment
from sphinx.ext.autodoc import Options

company, name = "tox-dev", "tox"
release, version = __version__, ".".join(__version__.split(".")[:2])
copyright = f"{company}"
Expand Down Expand Up @@ -77,13 +79,13 @@


def process_signature(
app: Sphinx, # noqa: U100
app: Sphinx,
objtype: str,
name: str, # noqa: U100
obj: Any, # noqa: U100
name: str,
obj: Any,
options: Options,
args: str, # noqa: U100
retann: str | None, # noqa: U100
args: str,
retann: str | None,
) -> None | tuple[None, None]:
# skip-member is not checked for class level docs, so disable via signature processing
return (None, None) if objtype == "class" and "__init__" in options.get("exclude-members", set()) else None
Expand Down Expand Up @@ -120,7 +122,6 @@ def resolve_xref(
}
if target in mapping:
target = node["reftarget"] = mapping[target]
# node.children[0].children[0] = Text(target, target)
return super().resolve_xref(env, fromdocname, builder, type, target, node, contnode)

app.connect("autodoc-process-signature", process_signature, priority=400)
Expand All @@ -130,7 +131,7 @@ def resolve_xref(

def check_uri(self, refnode: reference) -> None:
if refnode.document.attributes["source"].endswith("index.rst"):
return # do not use for the index file
return None # do not use for the index file
return prev_check(self, refnode)

prev_check, ExternalLinksChecker.check_uri = ExternalLinksChecker.check_uri, check_uri
8 changes: 5 additions & 3 deletions docs/tox_conf.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from __future__ import annotations

from typing import cast
from typing import TYPE_CHECKING, cast

from docutils.nodes import Element, Node, Text, container, fully_normalize_name, literal, paragraph, reference, strong
from docutils.parsers.rst.directives import flag, unchanged, unchanged_required
from docutils.parsers.rst.states import RSTState, RSTStateMachine
from docutils.statemachine import StringList, string2lines
from sphinx.domains.std import StandardDomain
from sphinx.locale import __
from sphinx.util.docutils import SphinxDirective
from sphinx.util.logging import getLogger

if TYPE_CHECKING:
from docutils.parsers.rst.states import RSTState, RSTStateMachine

LOGGER = getLogger(__name__)


Expand All @@ -37,7 +39,7 @@ def __init__(
block_text: str,
state: RSTState,
state_machine: RSTStateMachine,
):
) -> None:
super().__init__(
name,
arguments,
Expand Down
68 changes: 34 additions & 34 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.17",
"hatchling>=1.18",
]

[project]
Expand Down Expand Up @@ -33,13 +33,13 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"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",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Testing",
"Topic :: Utilities",
Expand All @@ -48,17 +48,17 @@ dynamic = [
"version",
]
dependencies = [
"cachetools>=5.3",
"cachetools>=5.3.1",
"chardet>=5.1",
"colorama>=0.4.6",
"filelock>=3.12",
"filelock>=3.12.2",
'importlib-metadata>=6.6; python_version < "3.8"',
"packaging>=23.1",
"platformdirs>=3.5.1",
"platformdirs>=3.5.3",
"pluggy>=1",
"pyproject-api>=1.5.1",
'tomli>=2.0.1; python_version < "3.11"',
'typing-extensions>=4.6.2; python_version < "3.8"',
'typing-extensions>=4.6.3; python_version < "3.8"',
"virtualenv>=20.23",
]
optional-dependencies.docs = [
Expand All @@ -69,19 +69,19 @@ optional-dependencies.docs = [
"sphinx-copybutton>=0.5.2",
"sphinx-inline-tabs>=2023.4.21",
"sphinxcontrib-towncrier>=0.2.1a0",
"towncrier>=22.12",
"towncrier>=23.6",
]
optional-dependencies.testing = [
"build[virtualenv]>=0.10",
"covdefaults>=2.3",
"devpi-process>=0.3",
"diff-cover>=7.5",
"diff-cover>=7.6",
"distlib>=0.3.6",
"flaky>=3.7",
"hatch-vcs>=0.3",
"hatchling>=1.17",
"hatchling>=1.18",
"psutil>=5.9.5",
"pytest>=7.3.1",
"pytest>=7.3.2",
"pytest-cov>=4.1",
"pytest-mock>=3.10",
"pytest-xdist>=3.3.1",
Expand All @@ -96,7 +96,6 @@ urls.Source = "https://github.com/tox-dev/tox"
urls.Tracker = "https://github.com/tox-dev/tox/issues"
scripts.tox = "tox.run:run"


[tool.hatch]
build.dev-mode-dirs = ["src"]
build.hooks.vcs.version-file = "src/tox/version.py"
Expand All @@ -106,6 +105,10 @@ version.source = "vcs"
[tool.black]
line-length = 120

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--tb=auto -ra --showlocals --no-success-flaky-report"

[tool.coverage]
html.show_contexts = true
html.skip_covered = false
Expand All @@ -122,11 +125,6 @@ report.omit = ["src/tox/config/cli/for_docs.py", "tests/execute/local_subprocess
run.parallel = true
run.plugins = ["covdefaults"]

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

[tool.mypy]
python_version = "3.11"
show_error_codes = true
Expand All @@ -145,24 +143,6 @@ overrides = [
], ignore_missing_imports = true },
]

[tool.pep8]
max-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"]
ignore = [
"E203", # whitespace before ':'
"W503", # line break before binary operator
]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--tb=auto -ra --showlocals --no-success-flaky-report"

[tool.towncrier]
name = "tox"
filename = "docs/changelog.rst"
Expand All @@ -171,3 +151,23 @@ title_format = false
issue_format = ":issue:`{issue}`"
template = "docs/changelog/template.jinja2"
# possible types, all default: feature, bugfix, doc, removal, misc

[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py37"
isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]}
ignore = [
"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
]
7 changes: 3 additions & 4 deletions src/tox/config/cli/env_var.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Provides configuration values from the environment variables.
"""
"""Provides configuration values from the environment variables."""
from __future__ import annotations

import logging
Expand All @@ -13,7 +11,8 @@


def get_env_var(key: str, of_type: type[Any]) -> tuple[Any, str] | None:
"""Get the environment variable option.
"""
Get the environment variable option.
:param key: the config key requested
:param of_type: the type we would like to convert it to
Expand Down
4 changes: 1 addition & 3 deletions src/tox/config/cli/ini.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Provides configuration values from tox.ini files.
"""
"""Provides configuration values from tox.ini files."""
from __future__ import annotations

import logging
Expand Down
9 changes: 3 additions & 6 deletions src/tox/config/cli/parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
This module pulls together this package: create and parse CLI arguments for tox.
"""
"""This module pulls together this package: create and parse CLI arguments for tox."""
from __future__ import annotations

import os
Expand Down Expand Up @@ -47,9 +45,8 @@ def _get_base(args: Sequence[str]) -> tuple[int, ToxHandler, Source]:
tox_parser = ToxParser.base()
parsed = Parsed()
try:
with open(os.devnull, "w") as file_handler:
with redirect_stderr(file_handler):
tox_parser.parse_known_args(args, namespace=parsed)
with open(os.devnull, "w") as file_handler, redirect_stderr(file_handler):
tox_parser.parse_known_args(args, namespace=parsed)
except SystemExit:
... # ignore parse errors, such as -va raises ignored explicit argument 'a'
guess_verbosity = parsed.verbosity
Expand Down

0 comments on commit 1136d62

Please sign in to comment.