Skip to content

Commit 44e2b69

Browse files
Justine Kosinskijustine202429
authored andcommitted
style: right formatting
1 parent 9a09f29 commit 44e2b69

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

pandas/io/formats/excel.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Utilities for conversion to writer-agnostic Excel representation.
33
"""
44

5-
from _future_ import annotations
5+
from __future__ import annotations
66

77
from collections.abc import (
88
Callable,
@@ -11,7 +11,6 @@
1111
Mapping,
1212
Sequence,
1313
)
14-
import pandas as pd
1514
import functools
1615
import itertools
1716
import re
@@ -64,10 +63,10 @@
6463

6564

6665
class ExcelCell:
67-
_fields_ = ("row", "col", "val", "style", "mergestart", "mergeend")
68-
_slots_ = _fields_
66+
__fields__ = ("row", "col", "val", "style", "mergestart", "mergeend")
67+
__slots__ = __fields__
6968

70-
def _init_(
69+
def __init__(
7170
self,
7271
row: int,
7372
col: int,
@@ -85,7 +84,7 @@ def _init_(
8584

8685

8786
class CssExcelCell(ExcelCell):
88-
def _init_(
87+
def __init__(
8988
self,
9089
row: int,
9190
col: int,
@@ -106,7 +105,7 @@ def _init_(
106105
unique_declarations = frozenset(declaration_dict.items())
107106
style = css_converter(unique_declarations)
108107

109-
super()._init_(row=row, col=col, val=val, style=style, **kwargs)
108+
super().__init__(row=row, col=col, val=val, style=style, **kwargs)
110109

111110

112111
class CSSToExcelConverter:
@@ -117,14 +116,14 @@ class CSSToExcelConverter:
117116
focusing on font styling, backgrounds, borders and alignment.
118117
119118
Operates by first computing CSS styles in a fairly generic
120-
way (see :meth:⁠ compute_css ⁠) then determining Excel style
121-
properties from CSS properties (see :meth:⁠ build_xlstyle ⁠).
119+
way (see :meth: `compute_css`) then determining Excel style
120+
properties from CSS properties (see :meth: `build_xlstyle`).
122121
123122
Parameters
124123
----------
125124
inherited : str, optional
126125
CSS declarations understood to be the containing scope for the
127-
CSS processed by :meth:⁠ __call__ ⁠.
126+
CSS processed by :meth:`__call__`.
128127
"""
129128

130129
NAMED_COLORS = CSS4_COLORS
@@ -184,25 +183,25 @@ class CSSToExcelConverter:
184183
]
185184
}
186185

187-
# NB: Most of the methods here could be classmethods, as only _init_
188-
# and _call_ make use of instance attributes. We leave them as
186+
# NB: Most of the methods here could be classmethods, as only __init__
187+
# and __call__ make use of instance attributes. We leave them as
189188
# instancemethods so that users can easily experiment with extensions
190189
# without monkey-patching.
191190
inherited: dict[str, str] | None
192191

193-
def _init_(self, inherited: str | None = None) -> None:
192+
def __init__(self, inherited: str | None = None) -> None:
194193
if inherited is not None:
195194
self.inherited = self.compute_css(inherited)
196195
else:
197196
self.inherited = None
198-
# We should avoid cache on the _call_ method.
199-
# Otherwise once the method _call_ has been called
197+
# We should avoid cache on the __call__ method.
198+
# Otherwise once the method __call__ has been called
200199
# garbage collection no longer deletes the instance.
201200
self._call_cached = functools.cache(self._call_uncached)
202201

203202
compute_css = CSSResolver()
204203

205-
def _call_(
204+
def __call__(
206205
self, declarations: str | frozenset[tuple[str, str]]
207206
) -> dict[str, dict[str, str]]:
208207
"""
@@ -518,27 +517,27 @@ class ExcelFormatter:
518517
output row names (index)
519518
index_label : str or sequence, default None
520519
Column label for index column(s) if desired. If None is given, and
521-
⁠ header ⁠ and ⁠ index ⁠ are True, then the index names are used. A
520+
`header` and `index` are True, then the index names are used. A
522521
sequence should be given if the DataFrame uses MultiIndex.
523522
merge_cells : bool or 'columns', default False
524523
Format MultiIndex column headers and Hierarchical Rows as merged cells
525524
if True. Merge MultiIndex column headers only if 'columns'.
526525
.. versionchanged:: 3.0.0
527526
Added the 'columns' option.
528-
inf_rep : str, default ⁠ 'inf' ⁠
527+
inf_rep : str, default `'inf'`
529528
representation for np.inf values (which aren't representable in Excel)
530-
A ⁠ '-' ⁠ sign will be added in front of -inf.
529+
A `'-'` sign will be added in front of -inf.
531530
style_converter : callable, optional
532531
This translates Styler styles (CSS) into ExcelWriter styles.
533-
Defaults to `⁠ CSSToExcelConverter() ⁠`.
532+
Defaults to ``CSSToExcelConverter()``.
534533
It should have signature css_declarations string -> excel style.
535534
This is only called for body cells.
536535
"""
537536

538537
max_rows = 2**20
539538
max_cols = 2**14
540539

541-
def _init_(
540+
def __init__(
542541
self,
543542
df,
544543
na_rep: str = "",
@@ -928,8 +927,8 @@ def write(
928927
is to be frozen
929928
engine : string, default None
930929
write engine to use if writer is a path - you can also set this
931-
via the options `⁠ io.excel.xlsx.writer ⁠`,
932-
or `⁠ io.excel.xlsm.writer ⁠`.
930+
via the options ``io.excel.xlsx.writer``,
931+
or ``io.excel.xlsm.writer``.
933932
934933
{storage_options}
935934
@@ -971,4 +970,4 @@ def write(
971970
finally:
972971
# make sure to close opened file handles
973972
if need_save:
974-
writer.close()
973+
writer.close()

0 commit comments

Comments
 (0)