From 124fde40936b5e4f25412aa655e6d316a7287b36 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 08:18:37 -0800 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#426) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/check.yml | 2 +- .pre-commit-config.yaml | 23 ++++++++++++------- ignore-words.txt | 2 ++ pyproject.toml | 23 ++++++++++++++----- .../demo_typing_guard.py | 6 ++--- .../demo_typing_guard.py | 3 ++- tests/test_integration.py | 14 ++++++----- tests/test_sphinx_autodoc_typehints.py | 13 +++++++---- 8 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 ignore-words.txt diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2fc0144..681db5e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -2,7 +2,7 @@ name: check on: workflow_dispatch: push: - branches: "main" + branches: ["main"] tags-ignore: ["**"] pull_request: schedule: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb7572c..ab70beb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,15 +4,16 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.2.0" + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.28.0 hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/psf/black - rev: 24.1.1 + - id: check-github-workflows + args: [ "--verbose" ] + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 hooks: - - id: black + - id: codespell + additional_dependencies: ["tomli>=2.0.1"] - repo: https://github.com/tox-dev/tox-ini-fmt rev: "1.3.1" hooks: @@ -22,7 +23,13 @@ repos: rev: "1.7.0" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.11.4"] + additional_dependencies: ["tox>=4.12.1"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.2.1" + hooks: + - id: ruff-format + - id: ruff + args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"] - repo: meta hooks: - id: check-hooks-apply diff --git a/ignore-words.txt b/ignore-words.txt new file mode 100644 index 0000000..8efad7a --- /dev/null +++ b/ignore-words.txt @@ -0,0 +1,2 @@ +master +manuel diff --git a/pyproject.toml b/pyproject.toml index e593334..3f71c18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,27 +68,38 @@ version.source = "vcs" line-length = 120 [tool.ruff] -select = ["ALL"] line-length = 120 target-version = "py37" -isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]} -ignore = [ - "ANN101", # no typoe annotation for self +lint.select = ["ALL"] +lint.isort = {known-first-party = ["sphinx_autodoc_typehints", "tests"], required-imports = ["from __future__ import annotations"]} +lint.ignore = [ + "ANN101", # no type 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 + "COM812", # Conflict with formatter + "ISC001", # Conflict with formatter + "CPY", # No copyright statements ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.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 + "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 + "PLR0913", # any number of arguments in tests + "PLR0917", # any number of arguments in tests ] +[tool.codespell] +builtin = "clear,usage,en-GB_to_en-US" +ignore-words = "ignore-words.txt" +write-changes = true +count = true + [tool.pytest.ini_options] testpaths = ["tests"] diff --git a/tests/roots/test-resolve-typing-guard-tmp/demo_typing_guard.py b/tests/roots/test-resolve-typing-guard-tmp/demo_typing_guard.py index aabdbc4..a7bc328 100644 --- a/tests/roots/test-resolve-typing-guard-tmp/demo_typing_guard.py +++ b/tests/roots/test-resolve-typing-guard-tmp/demo_typing_guard.py @@ -17,7 +17,7 @@ class SomeClass: @classmethod def from_str(cls, input_value: str) -> SomeClass: # noqa: ANN102 """ - Initialise from string + Initialize from string :param input_value: Input :return: result @@ -27,7 +27,7 @@ def from_str(cls, input_value: str) -> SomeClass: # noqa: ANN102 @classmethod def from_date(cls, input_value: datetime.date) -> SomeClass: # noqa: ANN102 """ - Initialise from date + Initialize from date :param input_value: Input :return: result @@ -37,7 +37,7 @@ def from_date(cls, input_value: datetime.date) -> SomeClass: # noqa: ANN102 @classmethod def from_time(cls, input_value: datetime.time) -> SomeClass: # noqa: ANN102 """ - Initialise from time + Initialize from time :param input_value: Input :return: result diff --git a/tests/roots/test-resolve-typing-guard/demo_typing_guard.py b/tests/roots/test-resolve-typing-guard/demo_typing_guard.py index 8b3736d..cba5b42 100644 --- a/tests/roots/test-resolve-typing-guard/demo_typing_guard.py +++ b/tests/roots/test-resolve-typing-guard/demo_typing_guard.py @@ -55,7 +55,8 @@ def guarded(self, item: Decimal) -> None: """ -def func(_x: Literal) -> None: ... +def func(_x: Literal) -> None: + ... __all__ = [ diff --git a/tests/test_integration.py b/tests/test_integration.py index 88d25b8..7a1a61b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -625,11 +625,13 @@ def func_with_examples() -> int: @overload -def func_with_overload(a: int, b: int) -> None: ... +def func_with_overload(a: int, b: int) -> None: + ... @overload -def func_with_overload(a: str, b: str) -> None: ... +def func_with_overload(a: str, b: str) -> None: + ... @expected( @@ -1094,7 +1096,7 @@ def docstring_with_bullet_list_after_params(param: int) -> None: # noqa: ARG001 maybe multiple lines Next Term - Somethign about it + Something about it """, ) @@ -1110,7 +1112,7 @@ def docstring_with_definition_list_after_params(param: int) -> None: # noqa: AR maybe multiple lines Next Term - Somethign about it + Something about it """ @@ -1162,7 +1164,7 @@ def docstring_with_enum_list_after_params(param: int) -> None: # noqa: ARG001 maybe multiple lines Next Term - Somethign about it + Something about it -[ Example ]- """, @@ -1179,7 +1181,7 @@ def docstring_with_definition_list_after_params_no_blank_line(param: int) -> Non maybe multiple lines Next Term - Somethign about it + Something about it .. rubric:: Example """ diff --git a/tests/test_sphinx_autodoc_typehints.py b/tests/test_sphinx_autodoc_typehints.py index 0b68ce6..29440ca 100644 --- a/tests/test_sphinx_autodoc_typehints.py +++ b/tests/test_sphinx_autodoc_typehints.py @@ -34,6 +34,7 @@ import typing_extensions from sphinx.application import Sphinx from sphinx.config import Config + from sphinx_autodoc_typehints import ( _resolve_type_guarded_imports, backfill_type_hints, @@ -80,17 +81,20 @@ class A: def get_type(self) -> type: return type(self) - class Inner: ... + class Inner: + ... class B(Generic[T]): name = "Foo" # This is set to make sure the correct class name ("B") is picked up -class C(B[str]): ... +class C(B[str]): + ... -class D(typing_extensions.Protocol): ... +class D(typing_extensions.Protocol): + ... class E(typing_extensions.Protocol[T]): # type: ignore[misc] @@ -101,7 +105,8 @@ class Slotted: __slots__ = () -class Metaclass(type): ... +class Metaclass(type): + ... class HintedMethods: