Skip to content

Commit 9b6d66e

Browse files
authored
CI: Update version of 'black' (#36493)
1 parent 16df8a4 commit 9b6d66e

25 files changed

+56
-76
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/python/black
3-
rev: 19.10b0
3+
rev: 20.8b1
44
hooks:
55
- id: black
66
language_version: python3

asv_bench/benchmarks/arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def setup(self, op):
125125
arr1 = np.random.randn(n_rows, int(n_cols / 2)).astype("f8")
126126
arr2 = np.random.randn(n_rows, int(n_cols / 2)).astype("f4")
127127
df = pd.concat(
128-
[pd.DataFrame(arr1), pd.DataFrame(arr2)], axis=1, ignore_index=True,
128+
[pd.DataFrame(arr1), pd.DataFrame(arr2)], axis=1, ignore_index=True
129129
)
130130
# should already be the case, but just to be sure
131131
df._consolidate_inplace()

doc/make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def main():
286286

287287
joined = ",".join(cmds)
288288
argparser = argparse.ArgumentParser(
289-
description="pandas documentation builder", epilog=f"Commands: {joined}",
289+
description="pandas documentation builder", epilog=f"Commands: {joined}"
290290
)
291291

292292
joined = ", ".join(cmds)

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308

309309
for method in methods:
310310
# ... and each of its public methods
311-
moved_api_pages.append((f"{old}.{method}", f"{new}.{method}",))
311+
moved_api_pages.append((f"{old}.{method}", f"{new}.{method}"))
312312

313313
if pattern is None:
314314
html_additional_pages = {

doc/source/development/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ submitting code to run the check yourself::
720720
to auto-format your code. Additionally, many editors have plugins that will
721721
apply ``black`` as you edit files.
722722

723-
You should use a ``black`` version >= 19.10b0 as previous versions are not compatible
723+
You should use a ``black`` version 20.8b1 as previous versions are not compatible
724724
with the pandas codebase.
725725

726726
If you wish to run these checks automatically, we encourage you to use

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
- cython>=0.29.21
1616

1717
# code checks
18-
- black=19.10b0
18+
- black=20.8b1
1919
- cpplint
2020
- flake8<3.8.0 # temporary pin, GH#34150
2121
- flake8-comprehensions>=3.1.0 # used by flake8, linting of unnecessary comprehensions

pandas/_vendored/typing_extensions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,8 +2116,7 @@ def __init_subclass__(cls, *args, **kwargs):
21162116
raise TypeError(f"Cannot subclass {cls.__module__}.Annotated")
21172117

21182118
def _strip_annotations(t):
2119-
"""Strips the annotations from a given type.
2120-
"""
2119+
"""Strips the annotations from a given type."""
21212120
if isinstance(t, _AnnotatedAlias):
21222121
return _strip_annotations(t.__origin__)
21232122
if isinstance(t, typing._GenericAlias):

pandas/core/aggregation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def validate_func_kwargs(
387387

388388

389389
def transform(
390-
obj: FrameOrSeries, func: AggFuncType, axis: Axis, *args, **kwargs,
390+
obj: FrameOrSeries, func: AggFuncType, axis: Axis, *args, **kwargs
391391
) -> FrameOrSeries:
392392
"""
393393
Transform a DataFrame or Series

pandas/core/algorithms.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,11 +1022,10 @@ def checked_add_with_arr(arr, b, arr_mask=None, b_mask=None):
10221022
to_raise = ((np.iinfo(np.int64).max - b2 < arr) & not_nan).any()
10231023
else:
10241024
to_raise = (
1025-
((np.iinfo(np.int64).max - b2[mask1] < arr[mask1]) & not_nan[mask1]).any()
1026-
or (
1027-
(np.iinfo(np.int64).min - b2[mask2] > arr[mask2]) & not_nan[mask2]
1028-
).any()
1029-
)
1025+
(np.iinfo(np.int64).max - b2[mask1] < arr[mask1]) & not_nan[mask1]
1026+
).any() or (
1027+
(np.iinfo(np.int64).min - b2[mask2] > arr[mask2]) & not_nan[mask2]
1028+
).any()
10301029

10311030
if to_raise:
10321031
raise OverflowError("Overflow in int64 addition")

pandas/core/array_algos/replace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def compare_or_regex_search(
20-
a: ArrayLike, b: Union[Scalar, Pattern], regex: bool, mask: ArrayLike,
20+
a: ArrayLike, b: Union[Scalar, Pattern], regex: bool, mask: ArrayLike
2121
) -> Union[ArrayLike, bool]:
2222
"""
2323
Compare two array_like inputs of the same shape or two scalar values

pandas/core/frame.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,7 @@ def __init__(
449449
if isinstance(data, BlockManager):
450450
if index is None and columns is None and dtype is None and copy is False:
451451
# GH#33357 fastpath
452-
NDFrame.__init__(
453-
self, data,
454-
)
452+
NDFrame.__init__(self, data)
455453
return
456454

457455
mgr = self._init_mgr(
@@ -5748,7 +5746,7 @@ def nsmallest(self, n, columns, keep="first") -> DataFrame:
57485746
population GDP alpha-2
57495747
Tuvalu 11300 38 TV
57505748
Anguilla 11300 311 AI
5751-
Iceland 337000 17036 IS
5749+
Iceland 337000 17036 IS
57525750
57535751
When using ``keep='last'``, ties are resolved in reverse order:
57545752
@@ -7143,7 +7141,7 @@ def unstack(self, level=-1, fill_value=None):
71437141

71447142
return unstack(self, level, fill_value)
71457143

7146-
@Appender(_shared_docs["melt"] % dict(caller="df.melt(", other="melt",))
7144+
@Appender(_shared_docs["melt"] % dict(caller="df.melt(", other="melt"))
71477145
def melt(
71487146
self,
71497147
id_vars=None,
@@ -8625,7 +8623,7 @@ def blk_func(values):
86258623
# After possibly _get_data and transposing, we are now in the
86268624
# simple case where we can use BlockManager.reduce
86278625
res = df._mgr.reduce(blk_func)
8628-
out = df._constructor(res,).iloc[0].rename(None)
8626+
out = df._constructor(res).iloc[0].rename(None)
86298627
if out_dtype is not None:
86308628
out = out.astype(out_dtype)
86318629
if axis == 0 and is_object_dtype(out.dtype):

pandas/core/series.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
198198
# Constructors
199199

200200
def __init__(
201-
self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False,
201+
self, data=None, index=None, dtype=None, name=None, copy=False, fastpath=False
202202
):
203203

204204
if (
@@ -208,9 +208,7 @@ def __init__(
208208
and copy is False
209209
):
210210
# GH#33357 called with just the SingleBlockManager
211-
NDFrame.__init__(
212-
self, data,
213-
)
211+
NDFrame.__init__(self, data)
214212
self.name = name
215213
return
216214

@@ -329,9 +327,7 @@ def __init__(
329327

330328
data = SingleBlockManager.from_array(data, index)
331329

332-
generic.NDFrame.__init__(
333-
self, data,
334-
)
330+
generic.NDFrame.__init__(self, data)
335331
self.name = name
336332
self._set_axis(0, index, fastpath=True)
337333

pandas/core/sorting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_indexer_indexer(
7272
)
7373
elif isinstance(target, ABCMultiIndex):
7474
indexer = lexsort_indexer(
75-
target._get_codes_for_sorting(), orders=ascending, na_position=na_position,
75+
target._get_codes_for_sorting(), orders=ascending, na_position=na_position
7676
)
7777
else:
7878
# Check monotonic-ness before sort an index (GH 11080)

pandas/core/util/numba_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def set_use_numba(enable: bool = False) -> None:
2525

2626

2727
def get_jit_arguments(
28-
engine_kwargs: Optional[Dict[str, bool]] = None, kwargs: Optional[Dict] = None,
28+
engine_kwargs: Optional[Dict[str, bool]] = None, kwargs: Optional[Dict] = None
2929
) -> Tuple[bool, bool, bool]:
3030
"""
3131
Return arguments to pass to numba.JIT, falling back on pandas default JIT settings.

pandas/io/formats/format.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,6 @@ def _format(x):
13821382

13831383

13841384
class FloatArrayFormatter(GenericArrayFormatter):
1385-
"""
1386-
1387-
"""
1388-
13891385
def __init__(self, *args, **kwargs):
13901386
super().__init__(*args, **kwargs)
13911387

pandas/io/formats/latex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def __init__(
4141
self.multirow = multirow
4242
self.clinebuf: List[List[int]] = []
4343
self.strcols = self._get_strcols()
44-
self.strrows: List[List[str]] = (
45-
list(zip(*self.strcols)) # type: ignore[arg-type]
44+
self.strrows: List[List[str]] = list(
45+
zip(*self.strcols) # type: ignore[arg-type]
4646
)
4747

4848
def get_strrow(self, row_num: int) -> str:

pandas/tests/arrays/sparse/test_array.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ def test_constructor_inferred_fill_value(self, data, fill_value):
193193
assert result == fill_value
194194

195195
@pytest.mark.parametrize("format", ["coo", "csc", "csr"])
196-
@pytest.mark.parametrize(
197-
"size", [0, 10],
198-
)
196+
@pytest.mark.parametrize("size", [0, 10])
199197
@td.skip_if_no_scipy
200198
def test_from_spmatrix(self, size, format):
201199
import scipy.sparse
@@ -693,17 +691,13 @@ def test_getslice_tuple(self):
693691
dense = np.array([np.nan, 0, 3, 4, 0, 5, np.nan, np.nan, 0])
694692

695693
sparse = SparseArray(dense)
696-
res = sparse[
697-
4:,
698-
] # noqa: E231
699-
exp = SparseArray(dense[4:,]) # noqa: E231
694+
res = sparse[(slice(4, None),)]
695+
exp = SparseArray(dense[4:])
700696
tm.assert_sp_array_equal(res, exp)
701697

702698
sparse = SparseArray(dense, fill_value=0)
703-
res = sparse[
704-
4:,
705-
] # noqa: E231
706-
exp = SparseArray(dense[4:,], fill_value=0) # noqa: E231
699+
res = sparse[(slice(4, None),)]
700+
exp = SparseArray(dense[4:], fill_value=0)
707701
tm.assert_sp_array_equal(res, exp)
708702

709703
msg = "too many indices for array"

pandas/tests/frame/test_analytics.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,14 +1060,14 @@ def test_any_all_bool_only(self):
10601060
(np.any, {"A": pd.Series([0.0, 1.0], dtype="float")}, True),
10611061
(np.all, {"A": pd.Series([0, 1], dtype=int)}, False),
10621062
(np.any, {"A": pd.Series([0, 1], dtype=int)}, True),
1063-
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="M8[ns]")}, False,),
1064-
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="M8[ns]")}, True,),
1065-
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True,),
1066-
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True,),
1067-
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="m8[ns]")}, False,),
1068-
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="m8[ns]")}, True,),
1069-
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True,),
1070-
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True,),
1063+
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="M8[ns]")}, False),
1064+
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="M8[ns]")}, True),
1065+
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True),
1066+
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="M8[ns]")}, True),
1067+
pytest.param(np.all, {"A": pd.Series([0, 1], dtype="m8[ns]")}, False),
1068+
pytest.param(np.any, {"A": pd.Series([0, 1], dtype="m8[ns]")}, True),
1069+
pytest.param(np.all, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True),
1070+
pytest.param(np.any, {"A": pd.Series([1, 2], dtype="m8[ns]")}, True),
10711071
(np.all, {"A": pd.Series([0, 1], dtype="category")}, False),
10721072
(np.any, {"A": pd.Series([0, 1], dtype="category")}, True),
10731073
(np.all, {"A": pd.Series([1, 2], dtype="category")}, True),

pandas/tests/io/test_gcs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding)
108108
compression_only = "gz"
109109
compression["method"] = "infer"
110110
path_gcs += f".{compression_only}"
111-
df.to_csv(
112-
path_gcs, compression=compression, encoding=encoding,
113-
)
111+
df.to_csv(path_gcs, compression=compression, encoding=encoding)
114112
assert gcs_buffer.getvalue() == buffer.getvalue()
115113
read_df = read_csv(path_gcs, index_col=0, compression="infer", encoding=encoding)
116114
tm.assert_frame_equal(df, read_df)

pandas/tests/io/test_parquet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def test_s3_roundtrip(self, df_compat, s3_resource, pa, s3so):
572572
pytest.param(
573573
["A"],
574574
marks=pytest.mark.xfail(
575-
PY38, reason="Getting back empty DataFrame", raises=AssertionError,
575+
PY38, reason="Getting back empty DataFrame", raises=AssertionError
576576
),
577577
),
578578
[],

pandas/tests/scalar/timestamp/test_constructors.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,20 @@ def test_constructor_keyword(self):
259259
Timestamp("20151112")
260260
)
261261

262-
assert repr(
263-
Timestamp(
264-
year=2015,
265-
month=11,
266-
day=12,
267-
hour=1,
268-
minute=2,
269-
second=3,
270-
microsecond=999999,
262+
assert (
263+
repr(
264+
Timestamp(
265+
year=2015,
266+
month=11,
267+
day=12,
268+
hour=1,
269+
minute=2,
270+
second=3,
271+
microsecond=999999,
272+
)
271273
)
272-
) == repr(Timestamp("2015-11-12 01:02:03.999999"))
274+
== repr(Timestamp("2015-11-12 01:02:03.999999"))
275+
)
273276

274277
def test_constructor_fromordinal(self):
275278
base = datetime(2000, 1, 1)

pandas/tests/series/test_operators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,7 @@ def test_unary_minus_nullable_int(
554554
expected = pd.Series(target, dtype=dtype)
555555
tm.assert_series_equal(result, expected)
556556

557-
@pytest.mark.parametrize(
558-
"source", [[1, 2, 3], [1, 2, None], [-1, 0, 1]],
559-
)
557+
@pytest.mark.parametrize("source", [[1, 2, 3], [1, 2, None], [-1, 0, 1]])
560558
def test_unary_plus_nullable_int(self, any_signed_nullable_int_dtype, source):
561559
dtype = any_signed_nullable_int_dtype
562560
expected = pd.Series(source, dtype=dtype)

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ python-dateutil>=2.7.3
66
pytz
77
asv
88
cython>=0.29.21
9-
black==19.10b0
9+
black==20.8b1
1010
cpplint
1111
flake8<3.8.0
1212
flake8-comprehensions>=3.1.0

scripts/tests/test_validate_docstrings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77

88
class BadDocstrings:
9-
"""Everything here has a bad docstring
10-
"""
9+
"""Everything here has a bad docstring"""
1110

1211
def private_classes(self):
1312
"""

versioneer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
10731073
fmt = "tag '%s' doesn't start with prefix '%s'"
10741074
print(fmt % (full_tag, tag_prefix))
10751075
pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format(
1076-
full_tag, tag_prefix,
1076+
full_tag, tag_prefix
10771077
)
10781078
return pieces
10791079
pieces["closest-tag"] = full_tag[len(tag_prefix) :]

0 commit comments

Comments
 (0)