Skip to content

Commit 1117328

Browse files
CLN: D208 Docstring is over-indented (#31890)
1 parent 02887a5 commit 1117328

File tree

12 files changed

+115
-95
lines changed

12 files changed

+115
-95
lines changed

pandas/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def axis(request):
106106
@pytest.fixture(params=[0, "index"], ids=lambda x: f"axis {repr(x)}")
107107
def axis_series(request):
108108
"""
109-
Fixture for returning the axis numbers of a Series.
110-
"""
109+
Fixture for returning the axis numbers of a Series.
110+
"""
111111
return request.param
112112

113113

pandas/core/computation/pytables.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ def __init__(self, value, converted, kind: str):
601601
self.kind = kind
602602

603603
def tostring(self, encoding) -> str:
604-
""" quote the string if not encoded
605-
else encode and return """
604+
""" quote the string if not encoded else encode and return """
606605
if self.kind == "string":
607606
if encoding is not None:
608607
return str(self.converted)

pandas/io/excel/_xlrd.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def get_sheet_data(self, sheet, convert_float):
5757
epoch1904 = self.book.datemode
5858

5959
def _parse_cell(cell_contents, cell_typ):
60-
"""converts the contents of the cell into a pandas
61-
appropriate object"""
60+
"""
61+
converts the contents of the cell into a pandas appropriate object
62+
"""
6263

6364
if cell_typ == XL_CELL_DATE:
6465

pandas/io/formats/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ def to_html(
979979
border : int
980980
A ``border=border`` attribute is included in the opening
981981
``<table>`` tag. Default ``pd.options.display.html.border``.
982-
"""
982+
"""
983983
from pandas.io.formats.html import HTMLFormatter, NotebookFormatter
984984

985985
Klass = NotebookFormatter if notebook else HTMLFormatter

pandas/io/parsers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,10 @@ def _should_parse_dates(self, i):
14561456
def _extract_multi_indexer_columns(
14571457
self, header, index_names, col_names, passed_names=False
14581458
):
1459-
""" extract and return the names, index_names, col_names
1460-
header is a list-of-lists returned from the parsers """
1459+
"""
1460+
extract and return the names, index_names, col_names
1461+
header is a list-of-lists returned from the parsers
1462+
"""
14611463
if len(header) < 2:
14621464
return header[0], index_names, col_names, passed_names
14631465

pandas/io/pytables.py

Lines changed: 85 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,10 @@ def __getattr__(self, name: str):
569569
)
570570

571571
def __contains__(self, key: str) -> bool:
572-
""" check for existence of this key
573-
can match the exact pathname or the pathnm w/o the leading '/'
574-
"""
572+
"""
573+
check for existence of this key
574+
can match the exact pathname or the pathnm w/o the leading '/'
575+
"""
575576
node = self.get_node(key)
576577
if node is not None:
577578
name = node._v_pathname
@@ -1831,18 +1832,19 @@ def get_result(self, coordinates: bool = False):
18311832

18321833

18331834
class IndexCol:
1834-
""" an index column description class
1835+
"""
1836+
an index column description class
18351837
1836-
Parameters
1837-
----------
1838+
Parameters
1839+
----------
18381840
1839-
axis : axis which I reference
1840-
values : the ndarray like converted values
1841-
kind : a string description of this type
1842-
typ : the pytables type
1843-
pos : the position in the pytables
1841+
axis : axis which I reference
1842+
values : the ndarray like converted values
1843+
kind : a string description of this type
1844+
typ : the pytables type
1845+
pos : the position in the pytables
18441846
1845-
"""
1847+
"""
18461848

18471849
is_an_indexable = True
18481850
is_data_indexable = True
@@ -1999,9 +2001,11 @@ def __iter__(self):
19992001
return iter(self.values)
20002002

20012003
def maybe_set_size(self, min_itemsize=None):
2002-
""" maybe set a string col itemsize:
2003-
min_itemsize can be an integer or a dict with this columns name
2004-
with an integer size """
2004+
"""
2005+
maybe set a string col itemsize:
2006+
min_itemsize can be an integer or a dict with this columns name
2007+
with an integer size
2008+
"""
20052009
if _ensure_decoded(self.kind) == "string":
20062010

20072011
if isinstance(min_itemsize, dict):
@@ -2051,8 +2055,10 @@ def validate_attr(self, append: bool):
20512055
)
20522056

20532057
def update_info(self, info):
2054-
""" set/update the info for this indexable with the key/value
2055-
if there is a conflict raise/warn as needed """
2058+
"""
2059+
set/update the info for this indexable with the key/value
2060+
if there is a conflict raise/warn as needed
2061+
"""
20562062

20572063
for key in self._info_fields:
20582064

@@ -2140,17 +2146,18 @@ def set_attr(self):
21402146

21412147

21422148
class DataCol(IndexCol):
2143-
""" a data holding column, by definition this is not indexable
2149+
"""
2150+
a data holding column, by definition this is not indexable
21442151
2145-
Parameters
2146-
----------
2152+
Parameters
2153+
----------
21472154
2148-
data : the actual data
2149-
cname : the column name in the table to hold the data (typically
2150-
values)
2151-
meta : a string description of the metadata
2152-
metadata : the actual metadata
2153-
"""
2155+
data : the actual data
2156+
cname : the column name in the table to hold the data (typically
2157+
values)
2158+
meta : a string description of the metadata
2159+
metadata : the actual metadata
2160+
"""
21542161

21552162
is_an_indexable = False
21562163
is_data_indexable = False
@@ -2460,16 +2467,17 @@ class GenericDataIndexableCol(DataIndexableCol):
24602467

24612468

24622469
class Fixed:
2463-
""" represent an object in my store
2464-
facilitate read/write of various types of objects
2465-
this is an abstract base class
2470+
"""
2471+
represent an object in my store
2472+
facilitate read/write of various types of objects
2473+
this is an abstract base class
24662474
2467-
Parameters
2468-
----------
2469-
parent : HDFStore
2470-
group : Node
2471-
The group node where the table resides.
2472-
"""
2475+
Parameters
2476+
----------
2477+
parent : HDFStore
2478+
group : Node
2479+
The group node where the table resides.
2480+
"""
24732481

24742482
pandas_kind: str
24752483
format_type: str = "fixed" # GH#30962 needed by dask
@@ -2596,8 +2604,10 @@ def validate_version(self, where=None):
25962604
return True
25972605

25982606
def infer_axes(self):
2599-
""" infer the axes of my storer
2600-
return a boolean indicating if we have a valid storer or not """
2607+
"""
2608+
infer the axes of my storer
2609+
return a boolean indicating if we have a valid storer or not
2610+
"""
26012611

26022612
s = self.storable
26032613
if s is None:
@@ -3105,29 +3115,29 @@ class FrameFixed(BlockManagerFixed):
31053115

31063116

31073117
class Table(Fixed):
3108-
""" represent a table:
3109-
facilitate read/write of various types of tables
3110-
3111-
Attrs in Table Node
3112-
-------------------
3113-
These are attributes that are store in the main table node, they are
3114-
necessary to recreate these tables when read back in.
3115-
3116-
index_axes : a list of tuples of the (original indexing axis and
3117-
index column)
3118-
non_index_axes: a list of tuples of the (original index axis and
3119-
columns on a non-indexing axis)
3120-
values_axes : a list of the columns which comprise the data of this
3121-
table
3122-
data_columns : a list of the columns that we are allowing indexing
3123-
(these become single columns in values_axes), or True to force all
3124-
columns
3125-
nan_rep : the string to use for nan representations for string
3126-
objects
3127-
levels : the names of levels
3128-
metadata : the names of the metadata columns
3129-
3130-
"""
3118+
"""
3119+
represent a table:
3120+
facilitate read/write of various types of tables
3121+
3122+
Attrs in Table Node
3123+
-------------------
3124+
These are attributes that are store in the main table node, they are
3125+
necessary to recreate these tables when read back in.
3126+
3127+
index_axes : a list of tuples of the (original indexing axis and
3128+
index column)
3129+
non_index_axes: a list of tuples of the (original index axis and
3130+
columns on a non-indexing axis)
3131+
values_axes : a list of the columns which comprise the data of this
3132+
table
3133+
data_columns : a list of the columns that we are allowing indexing
3134+
(these become single columns in values_axes), or True to force all
3135+
columns
3136+
nan_rep : the string to use for nan representations for string
3137+
objects
3138+
levels : the names of levels
3139+
metadata : the names of the metadata columns
3140+
"""
31313141

31323142
pandas_kind = "wide_table"
31333143
format_type: str = "table" # GH#30962 needed by dask
@@ -4080,10 +4090,11 @@ def read_column(
40804090

40814091

40824092
class WORMTable(Table):
4083-
""" a write-once read-many table: this format DOES NOT ALLOW appending to a
4084-
table. writing is a one-time operation the data are stored in a format
4085-
that allows for searching the data on disk
4086-
"""
4093+
"""
4094+
a write-once read-many table: this format DOES NOT ALLOW appending to a
4095+
table. writing is a one-time operation the data are stored in a format
4096+
that allows for searching the data on disk
4097+
"""
40874098

40884099
table_type = "worm"
40894100

@@ -4094,14 +4105,16 @@ def read(
40944105
start: Optional[int] = None,
40954106
stop: Optional[int] = None,
40964107
):
4097-
""" read the indices and the indexing array, calculate offset rows and
4098-
return """
4108+
"""
4109+
read the indices and the indexing array, calculate offset rows and return
4110+
"""
40994111
raise NotImplementedError("WORMTable needs to implement read")
41004112

41014113
def write(self, **kwargs):
4102-
""" write in a format that we can search later on (but cannot append
4103-
to): write out the indices and the values using _write_array
4104-
(e.g. a CArray) create an indexing table so that we can search
4114+
"""
4115+
write in a format that we can search later on (but cannot append
4116+
to): write out the indices and the values using _write_array
4117+
(e.g. a CArray) create an indexing table so that we can search
41054118
"""
41064119
raise NotImplementedError("WORMTable needs to implement write")
41074120

@@ -4170,8 +4183,9 @@ def write(
41704183
table.write_data(chunksize, dropna=dropna)
41714184

41724185
def write_data(self, chunksize: Optional[int], dropna: bool = False):
4173-
""" we form the data into a 2-d including indexes,values,mask
4174-
write chunk-by-chunk """
4186+
"""
4187+
we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
4188+
"""
41754189

41764190
names = self.dtype.names
41774191
nrows = self.nrows_expected

pandas/io/sas/sas7bdat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ def column_data_offsets(self):
120120
return np.asarray(self._column_data_offsets, dtype=np.int64)
121121

122122
def column_types(self):
123-
"""Returns a numpy character array of the column types:
124-
s (string) or d (double)"""
123+
"""
124+
Returns a numpy character array of the column types:
125+
s (string) or d (double)
126+
"""
125127
return np.asarray(self._column_types, dtype=np.dtype("S1"))
126128

127129
def close(self):

pandas/plotting/_matplotlib/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,11 @@ def _adorn_subplots(self):
509509
self.axes[0].set_title(self.title)
510510

511511
def _apply_axis_properties(self, axis, rot=None, fontsize=None):
512-
""" Tick creation within matplotlib is reasonably expensive and is
513-
internally deferred until accessed as Ticks are created/destroyed
514-
multiple times per draw. It's therefore beneficial for us to avoid
515-
accessing unless we will act on the Tick.
512+
"""
513+
Tick creation within matplotlib is reasonably expensive and is
514+
internally deferred until accessed as Ticks are created/destroyed
515+
multiple times per draw. It's therefore beneficial for us to avoid
516+
accessing unless we will act on the Tick.
516517
"""
517518

518519
if rot is not None or fontsize is not None:

pandas/tests/extension/test_datetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def data_missing_for_sorting(dtype):
4444
@pytest.fixture
4545
def data_for_grouping(dtype):
4646
"""
47-
Expected to be like [B, B, NA, NA, A, A, B, C]
47+
Expected to be like [B, B, NA, NA, A, A, B, C]
4848
49-
Where A < B < C and NA is missing
49+
Where A < B < C and NA is missing
5050
"""
5151
a = pd.Timestamp("2000-01-01")
5252
b = pd.Timestamp("2000-01-02")

pandas/tests/generic/test_generic.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ def _axes(self):
2323
return self._typ._AXIS_ORDERS
2424

2525
def _construct(self, shape, value=None, dtype=None, **kwargs):
26-
""" construct an object for the given shape
27-
if value is specified use that if its a scalar
28-
if value is an array, repeat it as needed """
26+
"""
27+
construct an object for the given shape
28+
if value is specified use that if its a scalar
29+
if value is an array, repeat it as needed
30+
"""
2931

3032
if isinstance(shape, int):
3133
shape = tuple([shape] * self._ndim)

pandas/tests/groupby/test_groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ def test_groupby_reindex_inside_function():
14961496

14971497
def agg_before(hour, func, fix=False):
14981498
"""
1499-
Run an aggregate func on the subset of data.
1499+
Run an aggregate func on the subset of data.
15001500
"""
15011501

15021502
def _func(data):

pandas/tests/scalar/timestamp/test_unary_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,8 @@ def test_round_dst_border_nonexistent(self, method, ts_str, freq):
225225
],
226226
)
227227
def test_round_int64(self, timestamp, freq):
228-
"""check that all rounding modes are accurate to int64 precision
229-
see GH#22591
230-
"""
228+
# check that all rounding modes are accurate to int64 precision
229+
# see GH#22591
231230
dt = Timestamp(timestamp)
232231
unit = to_offset(freq).nanos
233232

0 commit comments

Comments
 (0)