Skip to content

Add docformatter. #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 6 additions & 7 deletions src/_pytask/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/_pytask/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

"""

Expand Down
13 changes: 6 additions & 7 deletions src/_pytask/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions tests/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 2 additions & 3 deletions tests/test_debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down