diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ed62eca..703693d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.29.0 + rev: 0.29.2 hooks: - id: check-github-workflows args: [ "--verbose" ] @@ -20,12 +20,12 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.1.4" + rev: "2.2.1" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.14.2"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.4" + rev: "v0.6.3" hooks: - id: ruff-format - id: ruff diff --git a/tests/roots/test-dummy/dummy_module_future_annotations.py b/tests/roots/test-dummy/dummy_module_future_annotations.py index 389cc98..325cc91 100644 --- a/tests/roots/test-dummy/dummy_module_future_annotations.py +++ b/tests/roots/test-dummy/dummy_module_future_annotations.py @@ -2,10 +2,10 @@ def function_with_py310_annotations( - self, # noqa: ANN001, ARG001 - x: bool | None, # noqa: ARG001 - y: int | str | float, # noqa: ARG001,PYI041 - z: str | None = None, # noqa: ARG001 + self, # noqa: ANN001 + x: bool | None, + y: int | str | float, # noqa: PYI041 + z: str | None = None, ) -> str: """ Method docstring. diff --git a/tests/roots/test-dummy/dummy_module_simple.py b/tests/roots/test-dummy/dummy_module_simple.py index fed8cdf..b1b03ed 100644 --- a/tests/roots/test-dummy/dummy_module_simple.py +++ b/tests/roots/test-dummy/dummy_module_simple.py @@ -1,7 +1,7 @@ from __future__ import annotations -def function(x: bool, y: int = 1) -> str: # noqa: ARG001 +def function(x: bool, y: int = 1) -> str: """ Function docstring. diff --git a/tests/roots/test-dummy/dummy_module_simple_default_role.py b/tests/roots/test-dummy/dummy_module_simple_default_role.py index 758196f..3f575de 100644 --- a/tests/roots/test-dummy/dummy_module_simple_default_role.py +++ b/tests/roots/test-dummy/dummy_module_simple_default_role.py @@ -1,7 +1,7 @@ from __future__ import annotations -def function(x: bool, y: int) -> str: # noqa: ARG001 +def function(x: bool, y: int) -> str: """ Function docstring. diff --git a/tests/roots/test-dummy/dummy_module_simple_no_use_rtype.py b/tests/roots/test-dummy/dummy_module_simple_no_use_rtype.py index 8dc80e7..b7c8277 100644 --- a/tests/roots/test-dummy/dummy_module_simple_no_use_rtype.py +++ b/tests/roots/test-dummy/dummy_module_simple_no_use_rtype.py @@ -1,7 +1,7 @@ from __future__ import annotations -def function_no_returns(x: bool, y: int = 1) -> str: # noqa: ARG001 +def function_no_returns(x: bool, y: int = 1) -> str: """ Function docstring. @@ -10,7 +10,7 @@ def function_no_returns(x: bool, y: int = 1) -> str: # noqa: ARG001 """ -def function_returns_with_type(x: bool, y: int = 1) -> str: # noqa: ARG001 +def function_returns_with_type(x: bool, y: int = 1) -> str: """ Function docstring. @@ -20,7 +20,7 @@ def function_returns_with_type(x: bool, y: int = 1) -> str: # noqa: ARG001 """ -def function_returns_with_compound_type(x: bool, y: int = 1) -> str: # noqa: ARG001 +def function_returns_with_compound_type(x: bool, y: int = 1) -> str: """ Function docstring. @@ -30,7 +30,7 @@ def function_returns_with_compound_type(x: bool, y: int = 1) -> str: # noqa: AR """ -def function_returns_without_type(x: bool, y: int = 1) -> str: # noqa: ARG001 +def function_returns_without_type(x: bool, y: int = 1) -> str: """ Function docstring. diff --git a/tests/roots/test-dummy/dummy_module_without_complete_typehints.py b/tests/roots/test-dummy/dummy_module_without_complete_typehints.py index 44ca046..ce40ff3 100644 --- a/tests/roots/test-dummy/dummy_module_without_complete_typehints.py +++ b/tests/roots/test-dummy/dummy_module_without_complete_typehints.py @@ -1,7 +1,7 @@ from __future__ import annotations -def function_with_some_defaults_and_without_typehints(x, y=None): # noqa: ANN001, ANN201, ARG001 +def function_with_some_defaults_and_without_typehints(x, y=None): # noqa: ANN001, ANN201 """ Function docstring. @@ -10,7 +10,7 @@ def function_with_some_defaults_and_without_typehints(x, y=None): # noqa: ANN00 """ -def function_with_some_defaults_and_some_typehints(x: int, y=None): # noqa: ANN001, ANN201, ARG001 +def function_with_some_defaults_and_some_typehints(x: int, y=None): # noqa: ANN001, ANN201 """ Function docstring. @@ -19,7 +19,7 @@ def function_with_some_defaults_and_some_typehints(x: int, y=None): # noqa: ANN """ -def function_with_some_defaults_and_more_typehints(x: int, y=None) -> str: # noqa: ANN001, ARG001 +def function_with_some_defaults_and_more_typehints(x: int, y=None) -> str: # noqa: ANN001 """ Function docstring. @@ -28,7 +28,7 @@ def function_with_some_defaults_and_more_typehints(x: int, y=None) -> str: # no """ -def function_with_defaults_and_some_typehints(x: int = 0, y=None) -> str: # noqa: ANN001, ARG001 +def function_with_defaults_and_some_typehints(x: int = 0, y=None) -> str: # noqa: ANN001 """ Function docstring. diff --git a/tests/test_integration.py b/tests/test_integration.py index a9aec4c..c0f7ff5 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -50,7 +50,7 @@ def dec(val: T) -> T: @expected("mod.get_local_function()") def get_local_function(): # noqa: ANN201 - def wrapper(self) -> str: # noqa: ANN001, ARG001 + def wrapper(self) -> str: # noqa: ANN001 """ Wrapper """ @@ -271,7 +271,7 @@ def __init__(self, message: str) -> None: bytes """, ) -def function(x: bool, y: int, z_: Optional[str] = None) -> str: # noqa: ARG001, UP007 +def function(x: bool, y: int, z_: Optional[str] = None) -> str: # noqa: UP007 """ Function docstring. @@ -299,7 +299,7 @@ def function(x: bool, y: int, z_: Optional[str] = None) -> str: # noqa: ARG001, * ****kwargs** ("str") -- bar """, ) -def function_with_starred_documentation_param_names(*args: int, **kwargs: str): # noqa: ANN201, ARG001 +def function_with_starred_documentation_param_names(*args: int, **kwargs: str): # noqa: ANN201 r""" Function docstring. @@ -322,7 +322,7 @@ def function_with_starred_documentation_param_names(*args: int, **kwargs: str): **x** ("str") -- foo """, ) -def function_with_escaped_default(x: str = "\b"): # noqa: ANN201, ARG001 +def function_with_escaped_default(x: str = "\b"): # noqa: ANN201 """ Function docstring. @@ -341,7 +341,7 @@ def function_with_escaped_default(x: str = "\b"): # noqa: ANN201, ARG001 **x** (a.b.c) -- foo """, ) -def function_with_unresolvable_annotation(x: a.b.c): # noqa: ANN201, ARG001, F821 +def function_with_unresolvable_annotation(x: a.b.c): # noqa: ANN201, F821 """ Function docstring. @@ -365,8 +365,8 @@ def function_with_unresolvable_annotation(x: a.b.c): # noqa: ANN201, ARG001, F8 """, ) def function_with_typehint_comment( # noqa: ANN201 - x, # type: int # noqa: ANN001, ARG001 - y, # type: str # noqa: ANN001, ARG001 + x, # type: int # noqa: ANN001 + y, # type: str # noqa: ANN001 ): # type: (...) -> None """ @@ -457,7 +457,7 @@ def method_without_typehint(self, x): # noqa: ANN001, ANN201, ARG002, PLR6301 "None" """, ) -def function_with_typehint_comment_not_inline(x=None, *y, z, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN201, ARG001 +def function_with_typehint_comment_not_inline(x=None, *y, z, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN201 # type: (Union[str, bytes, None], *str, bytes, **int) -> None """ Function docstring. @@ -592,7 +592,7 @@ def __init__(self, func: Callable[[int, str], str]) -> None: **x** ("Mailbox") -- function """, ) -def mocked_import(x: Mailbox): # noqa: ANN201, ARG001 +def mocked_import(x: Mailbox): # noqa: ANN201 """ A docstring. @@ -648,7 +648,7 @@ def func_with_overload(a: str, b: str) -> None: ... "None" """, ) -def func_with_overload(a: Union[int, str], b: Union[int, str]) -> None: # noqa: ARG001, UP007 +def func_with_overload(a: Union[int, str], b: Union[int, str]) -> None: # noqa: UP007 """ f does the thing. The arguments can either be ints or strings but they must both have the same type. @@ -727,7 +727,7 @@ def func_with_examples_and_returns_after() -> int: More info about the function here. """, ) -def func_with_parameters_and_stuff_after(a: int, b: int) -> int: # noqa: ARG001 +def func_with_parameters_and_stuff_after(a: int, b: int) -> int: """A func :param a: a tells us something @@ -761,7 +761,7 @@ def func_with_parameters_and_stuff_after(a: int, b: int) -> int: # noqa: ARG001 int """, ) -def func_with_rtype_in_weird_spot(a: int, b: int) -> int: # noqa: ARG001 +def func_with_rtype_in_weird_spot(a: int, b: int) -> int: """A func :param a: a tells us something @@ -809,7 +809,7 @@ def func_with_rtype_in_weird_spot(a: int, b: int) -> int: # noqa: ARG001 More stuff here. """, ) -def empty_line_between_parameters(a: int, b: int) -> int: # noqa: ARG001 +def empty_line_between_parameters(a: int, b: int) -> int: """A func :param a: One of the following possibilities: @@ -1002,7 +1002,7 @@ def napoleon_returns() -> CodeType: """, ) -def google_docstrings(arg1: CodeType, arg2: ModuleType) -> CodeType: # noqa: ARG001 +def google_docstrings(arg1: CodeType, arg2: ModuleType) -> CodeType: """Summary line. Extended description of function. @@ -1034,7 +1034,7 @@ def google_docstrings(arg1: CodeType, arg2: ModuleType) -> CodeType: # noqa: AR """, ) -def docstring_with_multiline_note_after_params(param: int) -> None: # noqa: ARG001 +def docstring_with_multiline_note_after_params(param: int) -> None: """Do something. Args: @@ -1065,7 +1065,7 @@ def docstring_with_multiline_note_after_params(param: int) -> None: # noqa: ARG """, ) -def docstring_with_bullet_list_after_params(param: int) -> None: # noqa: ARG001 +def docstring_with_bullet_list_after_params(param: int) -> None: """Do something. Args: @@ -1098,7 +1098,7 @@ def docstring_with_bullet_list_after_params(param: int) -> None: # noqa: ARG001 """, ) -def docstring_with_definition_list_after_params(param: int) -> None: # noqa: ARG001 +def docstring_with_definition_list_after_params(param: int) -> None: """Do something. Args: @@ -1132,7 +1132,7 @@ def docstring_with_definition_list_after_params(param: int) -> None: # noqa: AR """, ) -def docstring_with_enum_list_after_params(param: int) -> None: # noqa: ARG001 +def docstring_with_enum_list_after_params(param: int) -> None: """Do something. Args: @@ -1167,7 +1167,7 @@ def docstring_with_enum_list_after_params(param: int) -> None: # noqa: ARG001 -[ Example ]- """, ) -def docstring_with_definition_list_after_params_no_blank_line(param: int) -> None: # noqa: ARG001 +def docstring_with_definition_list_after_params_no_blank_line(param: int) -> None: """Do something. Args: @@ -1292,7 +1292,7 @@ def typehints_use_signature(a: AsyncGenerator) -> AsyncGenerator: """, rst_prolog=prolog, ) -def docstring_with_multiline_note_after_params_prolog_replace(param: int) -> None: # noqa: ARG001 +def docstring_with_multiline_note_after_params_prolog_replace(param: int) -> None: """Do something. Args: @@ -1329,7 +1329,7 @@ def docstring_with_multiline_note_after_params_prolog_replace(param: int) -> Non """, rst_epilog=epilog, ) -def docstring_with_multiline_note_after_params_epilog_replace(param: int) -> None: # noqa: ARG001 +def docstring_with_multiline_note_after_params_epilog_replace(param: int) -> None: """Do something. Args: diff --git a/tests/test_integration_autodoc_type_aliases.py b/tests/test_integration_autodoc_type_aliases.py index 7d21971..de3e832 100644 --- a/tests/test_integration_autodoc_type_aliases.py +++ b/tests/test_integration_autodoc_type_aliases.py @@ -114,7 +114,7 @@ def g(s: AliasedClass) -> AliasedClass: """, ) -def function(x: ArrayLike, y: Schema) -> str: # noqa: ARG001 +def function(x: ArrayLike, y: Schema) -> str: """ Function docstring. diff --git a/tests/test_integration_issue_384.py b/tests/test_integration_issue_384.py index 66815e6..31b977b 100644 --- a/tests/test_integration_issue_384.py +++ b/tests/test_integration_issue_384.py @@ -59,7 +59,7 @@ def dec(val: T) -> T: """, ) -def function(x: int = 5, y: int = 10, z: int = 15) -> str: # noqa: ARG001 +def function(x: int = 5, y: int = 10, z: int = 15) -> str: """ Function docstring. diff --git a/tests/test_sphinx_autodoc_typehints.py b/tests/test_sphinx_autodoc_typehints.py index 94c1c86..77f1536 100644 --- a/tests/test_sphinx_autodoc_typehints.py +++ b/tests/test_sphinx_autodoc_typehints.py @@ -355,15 +355,15 @@ def test_parse_annotation(annotation: Any, module: str, class_name: str, args: t # Zero-length tuple remains pytest.param(Tuple[()], ":py:data:`~typing.Tuple`", id="Tuple-p"), # noqa: UP006 # Internal single tuple with simple types is flattened in the output - pytest.param(Tuple[(int,)], r":py:data:`~typing.Tuple`\ \[:py:class:`int`]", id="Tuple-p-int"), # noqa: UP006 + pytest.param(Tuple[int,], r":py:data:`~typing.Tuple`\ \[:py:class:`int`]", id="Tuple-p-int"), # noqa: UP006 pytest.param( - Tuple[(int, int)], # noqa: UP006 + Tuple[int, int], # noqa: UP006 r":py:data:`~typing.Tuple`\ \[:py:class:`int`, :py:class:`int`]", id="Tuple-p-int-int", # noqa: RUF100, UP006 ), # Ellipsis in single tuple also gets flattened pytest.param( - Tuple[(int, ...)], # noqa: UP006 + Tuple[int, ...], # noqa: UP006 r":py:data:`~typing.Tuple`\ \[:py:class:`int`, :py:data:`...`]", id="Tuple-p-Ellipsis", ),