Skip to content

Commit 6c35c86

Browse files
xcz011roberthdevries
authored andcommitted
TYP: Update type naming in formatter (pandas-dev#32345)
1 parent e9e6f0a commit 6c35c86

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,8 @@ def to_string(
758758
header: Union[bool, Sequence[str]] = True,
759759
index: bool = True,
760760
na_rep: str = "NaN",
761-
formatters: Optional[fmt.formatters_type] = None,
762-
float_format: Optional[fmt.float_format_type] = None,
761+
formatters: Optional[fmt.FormattersType] = None,
762+
float_format: Optional[fmt.FloatFormatType] = None,
763763
sparsify: Optional[bool] = None,
764764
index_names: bool = True,
765765
justify: Optional[str] = None,

pandas/io/formats/format.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@
8181
if TYPE_CHECKING:
8282
from pandas import Series, DataFrame, Categorical
8383

84-
formatters_type = Union[
84+
FormattersType = Union[
8585
List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable]
8686
]
87-
float_format_type = Union[str, Callable, "EngFormatter"]
87+
FloatFormatType = Union[str, Callable, "EngFormatter"]
8888

8989
common_docstring = """
9090
Parameters
@@ -455,7 +455,7 @@ class TableFormatter:
455455

456456
show_dimensions: Union[bool, str]
457457
is_truncated: bool
458-
formatters: formatters_type
458+
formatters: FormattersType
459459
columns: Index
460460

461461
@property
@@ -548,9 +548,9 @@ def __init__(
548548
header: Union[bool, Sequence[str]] = True,
549549
index: bool = True,
550550
na_rep: str = "NaN",
551-
formatters: Optional[formatters_type] = None,
551+
formatters: Optional[FormattersType] = None,
552552
justify: Optional[str] = None,
553-
float_format: Optional[float_format_type] = None,
553+
float_format: Optional[FloatFormatType] = None,
554554
sparsify: Optional[bool] = None,
555555
index_names: bool = True,
556556
line_width: Optional[int] = None,
@@ -1089,7 +1089,7 @@ def _get_column_name_list(self) -> List[str]:
10891089
def format_array(
10901090
values: Any,
10911091
formatter: Optional[Callable],
1092-
float_format: Optional[float_format_type] = None,
1092+
float_format: Optional[FloatFormatType] = None,
10931093
na_rep: str = "NaN",
10941094
digits: Optional[int] = None,
10951095
space: Optional[Union[str, int]] = None,
@@ -1171,7 +1171,7 @@ def __init__(
11711171
formatter: Optional[Callable] = None,
11721172
na_rep: str = "NaN",
11731173
space: Union[str, int] = 12,
1174-
float_format: Optional[float_format_type] = None,
1174+
float_format: Optional[FloatFormatType] = None,
11751175
justify: str = "right",
11761176
decimal: str = ".",
11771177
quoting: Optional[int] = None,
@@ -1278,7 +1278,7 @@ def __init__(self, *args, **kwargs):
12781278

12791279
def _value_formatter(
12801280
self,
1281-
float_format: Optional[float_format_type] = None,
1281+
float_format: Optional[FloatFormatType] = None,
12821282
threshold: Optional[Union[float, int]] = None,
12831283
) -> Callable:
12841284
"""Returns a function to be applied on each value to format it"""
@@ -1372,7 +1372,7 @@ def format_values_with(float_format):
13721372

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

0 commit comments

Comments
 (0)