Skip to content

TYP: Type annotations in pandas/io/formats/printing.py #30404

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 1 commit into from
Dec 23, 2019
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
4 changes: 2 additions & 2 deletions pandas/io/formats/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ def write_th(
----------
s : object
The data to be written inside the cell.
header : boolean, default False
header : bool, default False
Set to True if the <th> is for use inside <thead>. This will
cause min-width to be set if there is one.
indent : int, default 0
The indentation level of the cell.
tags : string, default None
tags : str, default None
Tags to include in the cell.

Returns
Expand Down
14 changes: 7 additions & 7 deletions pandas/io/formats/printing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
printing tools
Printing tools.
"""

import sys
Expand Down Expand Up @@ -182,13 +182,12 @@ def pprint_thing(
replacements
default_escapes : bool, default False
Whether the input escape characters replaces or adds to the defaults
max_seq_items : False, int, default None
Pass thru to other pretty printers to limit sequence printing
max_seq_items : int or None, default None
Pass through to other pretty printers to limit sequence printing

Returns
-------
str

"""

def as_escaped_string(
Expand Down Expand Up @@ -312,7 +311,6 @@ def format_object_summary(
Returns
-------
summary string

"""
from pandas.io.formats.console import get_console_size
from pandas.io.formats.format import _get_adjustment
Expand Down Expand Up @@ -346,15 +344,17 @@ def format_object_summary(
# adj can optionally handle unicode eastern asian width
adj = _get_adjustment()

def _extend_line(s, line, value, display_width, next_line_prefix):
def _extend_line(
s: str, line: str, value: str, display_width: int, next_line_prefix: str
) -> Tuple[str, str]:

if adj.len(line.rstrip()) + adj.len(value.rstrip()) >= display_width:
s += line.rstrip()
line = next_line_prefix
line += value
return s, line

def best_len(values):
def best_len(values: List[str]) -> int:
if values:
return max(adj.len(x) for x in values)
else:
Expand Down