From bf69601e8495eba222ce9410608daa4326ba28d5 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 6 Aug 2022 00:06:42 +0200 Subject: [PATCH 1/2] Add docformatter. Committed via https://github.com/asottile/all-repos --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 54816632..1a82c42d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,6 +43,11 @@ repos: rev: v1.20.2 hooks: - id: setup-cfg-fmt +- repo: https://github.com/myint/docformatter + rev: v1.3.1 + hooks: + - id: docformatter + args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] - repo: https://github.com/psf/black rev: 22.6.0 hooks: From 97af26f413881386f0612864de3e429d95136059 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Aug 2022 22:07:38 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytask/capture.py | 13 ++++++------- src/_pytask/hookspecs.py | 4 ++-- src/_pytask/warnings.py | 13 ++++++------- tests/test_capture.py | 7 +++++-- tests/test_debugging.py | 5 ++--- tests/test_task.py | 9 ++++++--- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/_pytask/capture.py b/src/_pytask/capture.py index 95cfb52b..4a43b291 100644 --- a/src/_pytask/capture.py +++ b/src/_pytask/capture.py @@ -136,12 +136,11 @@ def pytask_post_parse(config: dict[str, Any]) -> None: def _colorama_workaround() -> None: - """Ensure colorama is imported so that it attaches to the correct stdio - handles on Windows. + """Ensure colorama is imported so that it attaches to the correct stdio handles on + Windows. - colorama uses the terminal on import time. So if something does the - first import of colorama while I/O capture is active, colorama will - fail in various ways. + colorama uses the terminal on import time. So if something does the first import of + colorama while I/O capture is active, colorama will fail in various ways. """ if sys.platform.startswith("win32"): @@ -429,8 +428,8 @@ def snap(self) -> bytes: return res def done(self) -> None: - """Stop capturing, restore streams, return original capture file, - seeked to position zero.""" + """Stop capturing, restore streams, return original capture file, seeked to + position zero.""" self._assert_state("done", ("initialized", "started", "suspended", "done")) if self._state == "done": return diff --git a/src/_pytask/hookspecs.py b/src/_pytask/hookspecs.py index 923cd984..bbb2c6bb 100644 --- a/src/_pytask/hookspecs.py +++ b/src/_pytask/hookspecs.py @@ -388,8 +388,8 @@ def pytask_execute_task(session: Session, task: Task) -> Any: def pytask_execute_task_teardown(session: Session, task: Task) -> None: """Tear down task execution. - This hook is executed after the task has been executed. It allows to perform - clean-up operations or checks for missing products. + This hook is executed after the task has been executed. It allows to perform clean- + up operations or checks for missing products. """ diff --git a/src/_pytask/warnings.py b/src/_pytask/warnings.py index ef5d3002..6f5777cd 100644 --- a/src/_pytask/warnings.py +++ b/src/_pytask/warnings.py @@ -82,8 +82,10 @@ def catch_warnings_for_item( when: str | None = None, ) -> Generator[None, None, None]: """Context manager that catches warnings generated in the contained execution block. - ``item`` can be None if we are not in the context of an item execution. - Each warning captured triggers the ``pytest_warning_recorded`` hook. + + ``item`` can be None if we are not in the context of an item execution. Each warning + captured triggers the ``pytest_warning_recorded`` hook. + """ with warnings.catch_warnings(record=True) as log: # mypy can't infer that record=True means log is not None; help it. @@ -181,11 +183,8 @@ def parse_warning_filter( def _resolve_warning_category(category: str) -> type[Warning]: - """ - Copied from warnings._getcategory, but changed so it lets exceptions (specially - ImportErrors) propagate so we can get access to their tracebacks (#9218). - - """ + """Copied from warnings._getcategory, but changed so it lets exceptions (specially + ImportErrors) propagate so we can get access to their tracebacks (#9218).""" __tracebackhide__ = True if not category: return Warning diff --git a/tests/test_capture.py b/tests/test_capture.py index 7f5bf44e..6611f619 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -273,8 +273,11 @@ def test_unicode_and_str_mixture(self): pytest.raises(TypeError, f.write, b"hello") def test_write_bytes_to_buffer(self): - """In python3, stdout / stderr are text io wrappers (exposing a buffer - property of the underlying bytestream). See issue #1407 + """In python3, stdout / stderr are text io wrappers (exposing a buffer property + of the underlying bytestream). + + See issue #1407 + """ f = capture.CaptureIO() f.buffer.write(b"foo\r\n") diff --git a/tests/test_debugging.py b/tests/test_debugging.py index 1ad6e4ad..9e3e5752 100644 --- a/tests/test_debugging.py +++ b/tests/test_debugging.py @@ -326,9 +326,8 @@ def task_1(): @pytest.mark.skipif(not IS_PEXPECT_INSTALLED, reason="pexpect is not installed.") @pytest.mark.skipif(sys.platform == "win32", reason="pexpect cannot spawn on Windows.") def test_pdb_with_injected_do_debug(tmp_path): - """Simulates pdbpp, which injects Pdb into do_debug, and uses - self.__class__ in do_continue. - """ + """Simulates pdbpp, which injects Pdb into do_debug, and uses self.__class__ in + do_continue.""" source = """ import pdb diff --git a/tests/test_task.py b/tests/test_task.py index e95fc497..5158451e 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -360,9 +360,12 @@ def func(produces, content): @pytest.mark.end_to_end def test_parametrized_tasks_without_arguments_in_signature(tmp_path, runner): - """This happens when plugins replace the function with its own implementation. Then, - there is usually no point in adding arguments to the function signature. Or when - people build weird workarounds like the one below.""" + """This happens when plugins replace the function with its own implementation. + + Then, there is usually no point in adding arguments to the function signature. Or + when people build weird workarounds like the one below. + + """ source = f""" import pytask from pathlib import Path