Skip to content

Commit a31e160

Browse files
jbrockmendeljorisvandenbossche
authored andcommitted
CLN: assorted cleanups, mostly post-black fixups (#28857)
1 parent 7ea5c96 commit a31e160

28 files changed

+59
-66
lines changed

asv_bench/benchmarks/ctors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SeriesConstructors:
6767
def setup(self, data_fmt, with_index, dtype):
6868
if data_fmt in (gen_of_str, gen_of_tuples) and with_index:
6969
raise NotImplementedError(
70-
"Series constructors do not support " "using generators with indexes"
70+
"Series constructors do not support using generators with indexes"
7171
)
7272
N = 10 ** 4
7373
if dtype == "float":

asv_bench/benchmarks/eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def time_add(self, engine, threads):
2727

2828
def time_and(self, engine, threads):
2929
pd.eval(
30-
"(self.df > 0) & (self.df2 > 0) & " "(self.df3 > 0) & (self.df4 > 0)",
30+
"(self.df > 0) & (self.df2 > 0) & (self.df3 > 0) & (self.df4 > 0)",
3131
engine=engine,
3232
)
3333

asv_bench/benchmarks/io/hdf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ def time_write_store_table_dc(self):
8888

8989
def time_query_store_table_wide(self):
9090
self.store.select(
91-
"table_wide", where="index > self.start_wide and " "index < self.stop_wide"
91+
"table_wide", where="index > self.start_wide and index < self.stop_wide"
9292
)
9393

9494
def time_query_store_table(self):
95-
self.store.select("table", where="index > self.start and " "index < self.stop")
95+
self.store.select("table", where="index > self.start and index < self.stop")
9696

9797
def time_store_repr(self):
9898
repr(self.store)

doc/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,11 @@ def linkcode_resolve(domain, info):
628628
fn = os.path.relpath(fn, start=os.path.dirname(pandas.__file__))
629629

630630
if "+" in pandas.__version__:
631-
return "http://github.com/pandas-dev/pandas/blob/master/pandas/" "{}{}".format(
631+
return "http://github.com/pandas-dev/pandas/blob/master/pandas/{}{}".format(
632632
fn, linespec
633633
)
634634
else:
635-
return "http://github.com/pandas-dev/pandas/blob/" "v{}/pandas/{}{}".format(
635+
return "http://github.com/pandas-dev/pandas/blob/v{}/pandas/{}{}".format(
636636
pandas.__version__, fn, linespec
637637
)
638638

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Timezones
256256
Numeric
257257
^^^^^^^
258258
- Bug in :meth:`DataFrame.quantile` with zero-column :class:`DataFrame` incorrectly raising (:issue:`23925`)
259-
- :class:`DataFrame` inequality comparisons with object-dtype and ``complex`` entries failing to raise ``TypeError`` like their :class:`Series` counterparts (:issue:`28079`)
259+
- :class:`DataFrame` flex inequality comparisons methods (:meth:`DataFrame.lt`, :meth:`DataFrame.le`, :meth:`DataFrame.gt`, :meth: `DataFrame.ge`) with object-dtype and ``complex`` entries failing to raise ``TypeError`` like their :class:`Series` counterparts (:issue:`28079`)
260260
- Bug in :class:`DataFrame` logical operations (`&`, `|`, `^`) not matching :class:`Series` behavior by filling NA values (:issue:`28741`)
261261
-
262262

pandas/_libs/reduction.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ cdef class Reducer:
170170
PyArray_SETITEM(result, PyArray_ITER_DATA(it), res)
171171
chunk.data = chunk.data + self.increment
172172
PyArray_ITER_NEXT(it)
173-
except Exception, e:
174-
if hasattr(e, 'args'):
175-
e.args = e.args + (i,)
173+
except Exception as err:
174+
if hasattr(err, 'args'):
175+
err.args = err.args + (i,)
176176
raise
177177
finally:
178178
# so we don't free the wrong memory

pandas/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
249249
# tag
250250
full_tag = mo.group(1)
251251
if not full_tag.startswith(tag_prefix):
252-
fmt = "tag '{full_tag}' doesn't start with prefix " "'{tag_prefix}'"
252+
fmt = "tag '{full_tag}' doesn't start with prefix '{tag_prefix}'"
253253
msg = fmt.format(full_tag=full_tag, tag_prefix=tag_prefix)
254254
if verbose:
255255
print(msg)

pandas/core/apply.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,15 @@ def apply_series_generator(self):
341341
for i, v in enumerate(series_gen):
342342
results[i] = self.f(v)
343343
keys.append(v.name)
344-
except Exception as e:
345-
if hasattr(e, "args"):
344+
except Exception as err:
345+
if hasattr(err, "args"):
346346

347347
# make sure i is defined
348348
if i is not None:
349349
k = res_index[i]
350-
e.args = e.args + ("occurred at index %s" % pprint_thing(k),)
350+
err.args = err.args + (
351+
"occurred at index %s" % pprint_thing(k),
352+
)
351353
raise
352354

353355
self.results = results

pandas/io/sas/sas7bdat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def _read_next_page(self):
672672
return True
673673
elif len(self._cached_page) != self._page_length:
674674
self.close()
675-
msg = "failed to read complete page from file " "(read {:d} of {:d} bytes)"
675+
msg = "failed to read complete page from file (read {:d} of {:d} bytes)"
676676
raise ValueError(msg.format(len(self._cached_page), self._page_length))
677677

678678
self._read_page_header()

pandas/plotting/_core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ def _get_call_args(backend_name, data, args, kwargs):
685685
else:
686686
raise TypeError(
687687
(
688-
"Called plot accessor for type {}, expected " "Series or DataFrame"
688+
"Called plot accessor for type {}, expected Series or DataFrame"
689689
).format(type(data).__name__)
690690
)
691691

@@ -740,7 +740,7 @@ def __call__(self, *args, **kwargs):
740740
return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs)
741741
else:
742742
raise ValueError(
743-
("plot kind {} can only be used for " "data frames").format(kind)
743+
("plot kind {} can only be used for data frames").format(kind)
744744
)
745745
elif kind in self._series_kinds:
746746
if isinstance(data, ABCDataFrame):

pandas/plotting/_matplotlib/boxplot.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,7 @@ def plot_group(keys, values, ax):
331331
if return_type is None:
332332
return_type = "axes"
333333
if layout is not None:
334-
raise ValueError(
335-
"The 'layout' keyword is not supported when " "'by' is None"
336-
)
334+
raise ValueError("The 'layout' keyword is not supported when 'by' is None")
337335

338336
if ax is None:
339337
rc = {"figure.figsize": figsize} if figsize is not None else {}

pandas/plotting/_matplotlib/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _validate_color_args(self):
230230
"color" in self.kwds or "colors" in self.kwds
231231
) and self.colormap is not None:
232232
warnings.warn(
233-
"'color' and 'colormap' cannot be used " "simultaneously. Using 'color'"
233+
"'color' and 'colormap' cannot be used simultaneously. Using 'color'"
234234
)
235235

236236
if "color" in self.kwds and self.style is not None:

pandas/plotting/_matplotlib/hist.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _grouped_plot(
184184
if figsize == "default":
185185
# allowed to specify mpl default with 'default'
186186
warnings.warn(
187-
"figsize='default' is deprecated. Specify figure " "size by tuple instead",
187+
"figsize='default' is deprecated. Specify figure size by tuple instead",
188188
FutureWarning,
189189
stacklevel=5,
190190
)
@@ -298,9 +298,7 @@ def hist_series(
298298

299299
if by is None:
300300
if kwds.get("layout", None) is not None:
301-
raise ValueError(
302-
"The 'layout' keyword is not supported when " "'by' is None"
303-
)
301+
raise ValueError("The 'layout' keyword is not supported when 'by' is None")
304302
# hack until the plotting interface is a bit more unified
305303
fig = kwds.pop(
306304
"figure", plt.gcf() if plt.get_fignums() else plt.figure(figsize=figsize)
@@ -394,7 +392,7 @@ def hist_frame(
394392
naxes = len(data.columns)
395393

396394
if naxes == 0:
397-
raise ValueError("hist method requires numerical columns, " "nothing to plot.")
395+
raise ValueError("hist method requires numerical columns, nothing to plot.")
398396

399397
fig, axes = _subplots(
400398
naxes=naxes,

pandas/plotting/_matplotlib/style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _get_standard_colors(
2525
elif color is not None:
2626
if colormap is not None:
2727
warnings.warn(
28-
"'color' and 'colormap' cannot be used " "simultaneously. Using 'color'"
28+
"'color' and 'colormap' cannot be used simultaneously. Using 'color'"
2929
)
3030
colors = list(color) if is_list_like(color) else color
3131
else:

pandas/plotting/_matplotlib/tools.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ def _subplots(
188188
ax = _flatten(ax)
189189
if layout is not None:
190190
warnings.warn(
191-
"When passing multiple axes, layout keyword is " "ignored",
192-
UserWarning,
191+
"When passing multiple axes, layout keyword is ignored", UserWarning
193192
)
194193
if sharex or sharey:
195194
warnings.warn(

pandas/tests/io/test_html.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,8 @@ class ErrorThread(threading.Thread):
12331233
def run(self):
12341234
try:
12351235
super().run()
1236-
except Exception as e:
1237-
self.err = e
1236+
except Exception as err:
1237+
self.err = err
12381238
else:
12391239
self.err = None
12401240

pandas/tests/window/test_window.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_agg_function_support(self, arg):
6565
df = pd.DataFrame({"A": np.arange(5)})
6666
roll = df.rolling(2, win_type="triang")
6767

68-
msg = "'{arg}' is not a valid function for " "'Window' object".format(arg=arg)
68+
msg = "'{arg}' is not a valid function for 'Window' object".format(arg=arg)
6969
with pytest.raises(AttributeError, match=msg):
7070
roll.agg(arg)
7171

pandas/tseries/offsets.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,7 @@ def __init__(self, start="09:00", end="17:00", offset=timedelta(0)):
658658

659659
# Validation of input
660660
if len(start) != len(end):
661-
raise ValueError(
662-
"number of starting time and ending time " "must be the same"
663-
)
661+
raise ValueError("number of starting time and ending time must be the same")
664662
num_openings = len(start)
665663

666664
# sort starting and ending time by starting time
@@ -2242,7 +2240,7 @@ def _parse_suffix(cls, varion_code, startingMonth_code, weekday_code):
22422240
variation = "last"
22432241
else:
22442242
raise ValueError(
2245-
"Unable to parse varion_code: " "{code}".format(code=varion_code)
2243+
"Unable to parse varion_code: {code}".format(code=varion_code)
22462244
)
22472245

22482246
startingMonth = ccalendar.MONTH_TO_CAL_NUM[startingMonth_code]
@@ -2557,7 +2555,7 @@ def __init__(self, n=1, normalize=False):
25572555
BaseOffset.__init__(self, n, normalize)
25582556
if normalize:
25592557
raise ValueError(
2560-
"Tick offset with `normalize=True` are not " "allowed."
2558+
"Tick offset with `normalize=True` are not allowed."
25612559
) # GH#21427
25622560

25632561
__gt__ = _tick_comp(operator.gt)

pandas/util/_decorators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def deprecate_kwarg(
171171

172172
if mapping is not None and not hasattr(mapping, "get") and not callable(mapping):
173173
raise TypeError(
174-
"mapping from old to new argument values " "must be dict or callable!"
174+
"mapping from old to new argument values must be dict or callable!"
175175
)
176176

177177
def _deprecate_kwarg(func: F) -> F:
@@ -214,7 +214,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]:
214214
warnings.warn(msg, FutureWarning, stacklevel=stacklevel)
215215
if kwargs.get(new_arg_name) is not None:
216216
msg = (
217-
"Can only specify '{old_name}' or '{new_name}', " "not both"
217+
"Can only specify '{old_name}' or '{new_name}', not both"
218218
).format(old_name=old_arg_name, new_name=new_arg_name)
219219
raise TypeError(msg)
220220
else:

pandas/util/_exceptions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ def rewrite_exception(old_name, new_name):
66
"""Rewrite the message of an exception."""
77
try:
88
yield
9-
except Exception as e:
10-
msg = e.args[0]
9+
except Exception as err:
10+
msg = err.args[0]
1111
msg = msg.replace(old_name, new_name)
1212
args = (msg,)
13-
if len(e.args) > 1:
14-
args = args + e.args[1:]
15-
e.args = args
13+
if len(err.args) > 1:
14+
args = args + err.args[1:]
15+
err.args = args
1616
raise

pandas/util/_print_versions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def main():
139139
"--json",
140140
metavar="FILE",
141141
nargs=1,
142-
help="Save output as JSON into file, pass in " "'-' to output to stdout",
142+
help="Save output as JSON into file, pass in '-' to output to stdout",
143143
)
144144

145145
(options, args) = parser.parse_args()

pandas/util/_test_decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable:
185185
)
186186
skip_if_not_us_locale = pytest.mark.skipif(
187187
_skip_if_not_us_locale(),
188-
reason="Specific locale is set " "{lang}".format(lang=locale.getlocale()[0]),
188+
reason="Specific locale is set {lang}".format(lang=locale.getlocale()[0]),
189189
)
190190
skip_if_no_scipy = pytest.mark.skipif(
191191
_skip_if_no_scipy(), reason="Missing SciPy requirement"

pandas/util/_validators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def validate_axis_style_args(data, args, kwargs, arg_name, method_name):
289289
# First fill with explicit values provided by the user...
290290
if arg_name in kwargs:
291291
if args:
292-
msg = "{} got multiple values for argument " "'{}'".format(
292+
msg = "{} got multiple values for argument '{}'".format(
293293
method_name, arg_name
294294
)
295295
raise TypeError(msg)
@@ -318,7 +318,7 @@ def validate_axis_style_args(data, args, kwargs, arg_name, method_name):
318318
elif len(args) == 2:
319319
if "axis" in kwargs:
320320
# Unambiguously wrong
321-
msg = "Cannot specify both 'axis' and any of 'index' " "or 'columns'"
321+
msg = "Cannot specify both 'axis' and any of 'index' or 'columns'"
322322
raise TypeError(msg)
323323

324324
msg = (

pandas/util/testing.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ def assert_series_equal(
11751175
# vs Timestamp) but will compare equal
11761176
if not Index(left.values).equals(Index(right.values)):
11771177
msg = (
1178-
"[datetimelike_compat=True] {left} is not equal to " "{right}."
1178+
"[datetimelike_compat=True] {left} is not equal to {right}."
11791179
).format(left=left.values, right=right.values)
11801180
raise AssertionError(msg)
11811181
else:
@@ -2363,34 +2363,34 @@ def wrapper(*args, **kwargs):
23632363
skip()
23642364
try:
23652365
return t(*args, **kwargs)
2366-
except Exception as e:
2367-
errno = getattr(e, "errno", None)
2366+
except Exception as err:
2367+
errno = getattr(err, "errno", None)
23682368
if not errno and hasattr(errno, "reason"):
2369-
errno = getattr(e.reason, "errno", None)
2369+
errno = getattr(err.reason, "errno", None)
23702370

23712371
if errno in skip_errnos:
23722372
skip(
23732373
"Skipping test due to known errno"
2374-
" and error {error}".format(error=e)
2374+
" and error {error}".format(error=err)
23752375
)
23762376

2377-
e_str = str(e)
2377+
e_str = str(err)
23782378

23792379
if any(m.lower() in e_str.lower() for m in _skip_on_messages):
23802380
skip(
23812381
"Skipping test because exception "
2382-
"message is known and error {error}".format(error=e)
2382+
"message is known and error {error}".format(error=err)
23832383
)
23842384

2385-
if not isinstance(e, error_classes):
2385+
if not isinstance(err, error_classes):
23862386
raise
23872387

23882388
if raise_on_error or can_connect(url, error_classes):
23892389
raise
23902390
else:
23912391
skip(
23922392
"Skipping test due to lack of connectivity"
2393-
" and error {error}".format(error=e)
2393+
" and error {error}".format(error=err)
23942394
)
23952395

23962396
return wrapper

scripts/find_commits_touching_func.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
"--dir-masks",
4747
metavar="d_re(,d_re)*",
4848
default=[],
49-
help="comma separated list of regexes to match base " "path against",
49+
help="comma separated list of regexes to match base path against",
5050
)
5151
argparser.add_argument(
5252
"-p",
5353
"--path-masks",
5454
metavar="p_re(,p_re)*",
5555
default=[],
56-
help="comma separated list of regexes to match full " "file path against",
56+
help="comma separated list of regexes to match full file path against",
5757
)
5858
argparser.add_argument(
5959
"-y",
@@ -195,7 +195,7 @@ def sorter(i):
195195
return hits[i].path, d
196196

197197
print(
198-
("\nThese commits touched the %s method in these files " "on these dates:\n")
198+
("\nThese commits touched the %s method in these files on these dates:\n")
199199
% args.funcname
200200
)
201201
for i in sorted(range(len(hits)), key=sorter):

scripts/tests/test_validate_docstrings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ def test_bad_generic_functions(self, capsys, func):
10291029
(
10301030
"BadReturns",
10311031
"no_capitalization",
1032-
("Return value description should start with a capital " "letter",),
1032+
("Return value description should start with a capital letter",),
10331033
),
10341034
(
10351035
"BadReturns",

0 commit comments

Comments
 (0)