From d4a6b677fbf9483b75e1a5a42f2d510a84276197 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 17:16:54 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: 971923581912ef60a6b70dbf0c3e9a39563c9d47 → 0b19ef1fd6ad680ed7752d6daba883ce1265a6de](https://github.com/astral-sh/ruff-pre-commit/compare/971923581912ef60a6b70dbf0c3e9a39563c9d47...0b19ef1fd6ad680ed7752d6daba883ce1265a6de) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fa15182..285f854e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: args: [--prose-wrap=preserve] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "971923581912ef60a6b70dbf0c3e9a39563c9d47" # frozen: v0.11.4 + rev: "0b19ef1fd6ad680ed7752d6daba883ce1265a6de" # frozen: v0.12.2 hooks: - id: ruff args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"] From 37f6a7fa8cafc3d7bc3629a30bad9f8e0d7b9aad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 17:17:06 +0000 Subject: [PATCH 2/3] =?UTF-8?q?'[pre-commit.ci=20=F0=9F=A4=96]=20Apply=20c?= =?UTF-8?q?ode=20format=20tools=20to=20PR'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 285f854e..0e15402b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: args: [--prose-wrap=preserve] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "0b19ef1fd6ad680ed7752d6daba883ce1265a6de" # frozen: v0.12.2 + rev: "0b19ef1fd6ad680ed7752d6daba883ce1265a6de" # frozen: v0.12.2 hooks: - id: ruff args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"] From dbb31bbec8daf57cdc7a8bf27b599ea9d91496a7 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Mon, 7 Jul 2025 15:43:18 -0400 Subject: [PATCH 3/3] FIX: More --- numpydoc/__init__.py | 2 +- numpydoc/docscrape.py | 2 +- numpydoc/tests/test_docscrape.py | 8 ++------ numpydoc/tests/test_validate.py | 9 +++------ 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/numpydoc/__init__.py b/numpydoc/__init__.py index 5458b67f..381a4ab8 100644 --- a/numpydoc/__init__.py +++ b/numpydoc/__init__.py @@ -7,6 +7,6 @@ def setup(app, *args, **kwargs): - from .numpydoc import setup + from .numpydoc import setup # noqa: PLC0415 return setup(app, *args, **kwargs) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index 54863d5f..09d3b69e 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -627,7 +627,7 @@ def __init__(self, cls, doc=None, modulename="", func_doc=FunctionDoc, config=No self._cls = cls if "sphinx" in sys.modules: - from sphinx.ext.autodoc import ALL + from sphinx.ext.autodoc import ALL # noqa: PLC0415 else: ALL = object() diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py index f10adc45..09cfa4ce 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -2,7 +2,9 @@ import textwrap import warnings from collections import namedtuple +from collections.abc import Callable from copy import deepcopy +from functools import cached_property import jinja2 import pytest @@ -1623,7 +1625,6 @@ def test__error_location_no_name_attr(): See gh-362 """ - from collections.abc import Callable # Create a Callable that doesn't have a __name__ attribute class Foo: @@ -1644,7 +1645,6 @@ def __call__(self): def test_class_docstring_cached_property(): """Ensure that properties marked with the `cached_property` decorator are listed in the Methods section. See gh-432.""" - from functools import cached_property class Foo: _x = [1, 2, 3] @@ -1664,8 +1664,6 @@ def test_namedtuple_no_duplicate_attributes(): See gh-257 """ - from collections import namedtuple - foo = namedtuple("Foo", ("bar", "baz")) # Create the SphinxClassDoc object via get_doc_object @@ -1678,8 +1676,6 @@ def test_namedtuple_class_docstring(): See gh-257 """ - from collections import namedtuple - foo = namedtuple("Foo", ("bar", "baz")) class MyFoo(foo): diff --git a/numpydoc/tests/test_validate.py b/numpydoc/tests/test_validate.py index 9f0f7942..96d688d2 100644 --- a/numpydoc/tests/test_validate.py +++ b/numpydoc/tests/test_validate.py @@ -1390,12 +1390,9 @@ def test_bad_class(self, capsys): "too_short_header_underline", ], ) - def test_bad_generic_functions(self, capsys, func): - with pytest.warns(UserWarning): - errors = validate_one( - self._import_path(klass="WarnGenericFormat", func=func) - ) - assert "is too short" in w.msg + def test_bad_generic_functions_new(self, capsys, func): + with pytest.warns(UserWarning, match="is too short"): + validate_one(self._import_path(klass="WarnGenericFormat", func=func)) @pytest.mark.parametrize( "func",