Skip to content

TYP: Update type naming in formatter #32345

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
Feb 29, 2020
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/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,8 @@ def to_string(
header: Union[bool, Sequence[str]] = True,
index: bool = True,
na_rep: str = "NaN",
formatters: Optional[fmt.formatters_type] = None,
float_format: Optional[fmt.float_format_type] = None,
formatters: Optional[fmt.FormattersType] = None,
float_format: Optional[fmt.FloatFormatType] = None,
sparsify: Optional[bool] = None,
index_names: bool = True,
justify: Optional[str] = None,
Expand Down
18 changes: 9 additions & 9 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
if TYPE_CHECKING:
from pandas import Series, DataFrame, Categorical

formatters_type = Union[
FormattersType = Union[
List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable]
]
float_format_type = Union[str, Callable, "EngFormatter"]
FloatFormatType = Union[str, Callable, "EngFormatter"]

common_docstring = """
Parameters
Expand Down Expand Up @@ -455,7 +455,7 @@ class TableFormatter:

show_dimensions: Union[bool, str]
is_truncated: bool
formatters: formatters_type
formatters: FormattersType
columns: Index

@property
Expand Down Expand Up @@ -548,9 +548,9 @@ def __init__(
header: Union[bool, Sequence[str]] = True,
index: bool = True,
na_rep: str = "NaN",
formatters: Optional[formatters_type] = None,
formatters: Optional[FormattersType] = None,
justify: Optional[str] = None,
float_format: Optional[float_format_type] = None,
float_format: Optional[FloatFormatType] = None,
sparsify: Optional[bool] = None,
index_names: bool = True,
line_width: Optional[int] = None,
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def _get_column_name_list(self) -> List[str]:
def format_array(
values: Any,
formatter: Optional[Callable],
float_format: Optional[float_format_type] = None,
float_format: Optional[FloatFormatType] = None,
na_rep: str = "NaN",
digits: Optional[int] = None,
space: Optional[Union[str, int]] = None,
Expand Down Expand Up @@ -1171,7 +1171,7 @@ def __init__(
formatter: Optional[Callable] = None,
na_rep: str = "NaN",
space: Union[str, int] = 12,
float_format: Optional[float_format_type] = None,
float_format: Optional[FloatFormatType] = None,
justify: str = "right",
decimal: str = ".",
quoting: Optional[int] = None,
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def __init__(self, *args, **kwargs):

def _value_formatter(
self,
float_format: Optional[float_format_type] = None,
float_format: Optional[FloatFormatType] = None,
threshold: Optional[Union[float, int]] = None,
) -> Callable:
"""Returns a function to be applied on each value to format it"""
Expand Down Expand Up @@ -1372,7 +1372,7 @@ def format_values_with(float_format):

# There is a special default string when we are fixed-width
# The default is otherwise to use str instead of a formatting string
float_format: Optional[float_format_type]
float_format: Optional[FloatFormatType]
if self.float_format is None:
if self.fixed_width:
float_format = partial(
Expand Down