Skip to content
Open
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
17 changes: 11 additions & 6 deletions src/click/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class HelpFormatter:
width clamped to a maximum of 78.
"""

indent_increment: int
width: int
current_indent: int
buffer: list[str]

def __init__(
self,
indent_increment: int = 2,
Expand All @@ -135,8 +140,8 @@ def __init__(
if width is None:
width = max(min(shutil.get_terminal_size().columns, max_width) - 2, 50)
self.width = width
self.current_indent: int = 0
self.buffer: list[str] = []
self.current_indent = 0
self.buffer = []

def write(self, string: str) -> None:
"""Writes a unicode string into the internal buffer."""
Expand Down Expand Up @@ -223,7 +228,7 @@ def write_text(self, text: str) -> None:

def write_dl(
self,
rows: cabc.Sequence[tuple[str, str]],
rows: cabc.Iterable[tuple[str, str]],
col_max: int = 30,
col_spacing: int = 2,
) -> None:
Expand Down Expand Up @@ -266,7 +271,7 @@ def write_dl(
self.write("\n")

@contextmanager
def section(self, name: str) -> cabc.Iterator[None]:
def section(self, name: str) -> cabc.Generator[None]:
"""Helpful context manager that writes a paragraph, a heading,
and the indents.

Expand All @@ -281,7 +286,7 @@ def section(self, name: str) -> cabc.Iterator[None]:
self.dedent()

@contextmanager
def indentation(self) -> cabc.Iterator[None]:
def indentation(self) -> cabc.Generator[None]:
"""A context manager that increases the indentation."""
self.indent()
try:
Expand All @@ -294,7 +299,7 @@ def getvalue(self) -> str:
return "".join(self.buffer)


def join_options(options: cabc.Sequence[str]) -> tuple[str, bool]:
def join_options(options: cabc.Iterable[str]) -> tuple[str, bool]:
"""Given a list of option strings this joins them in the most appropriate
way and returns them in the form ``(formatted_string,
any_prefix_is_slash)`` where the second item in the tuple is a flag that
Expand Down
Loading