From de578bd38460a70b5abb9845a5121d3641b5a880 Mon Sep 17 00:00:00 2001 From: MarcoGorelli Date: Tue, 25 May 2021 09:23:12 +0100 Subject: [PATCH] pre-commit autoupdate (except for black formatter) --- .pre-commit-config.yaml | 8 ++++---- doc/sphinxext/announce.py | 4 ++-- pandas/_config/config.py | 2 +- pandas/core/reshape/merge.py | 4 ++-- pandas/core/reshape/tile.py | 2 +- pandas/io/formats/excel.py | 2 +- pandas/io/formats/latex.py | 8 ++++---- pandas/io/html.py | 2 +- pandas/io/pytables.py | 2 +- pandas/tests/generic/test_frame.py | 2 +- pandas/tests/generic/test_series.py | 2 +- pandas/tests/io/parser/test_c_parser_only.py | 10 +++++----- pandas/tests/io/parser/test_multi_thread.py | 2 +- pandas/tests/io/parser/test_skiprows.py | 4 ++-- pandas/tests/reshape/test_util.py | 2 +- pandas/util/_decorators.py | 12 +++++------- 16 files changed, 33 insertions(+), 35 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fbd3cf85383e..3078619ecac35 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,14 +19,14 @@ repos: types_or: [python, rst, markdown] files: ^(pandas|doc)/ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.0.1 hooks: - id: debug-statements - id: end-of-file-fixer exclude: \.txt$ - id: trailing-whitespace - repo: https://github.com/cpplint/cpplint - rev: f7061b1 # the latest tag does not have the hook + rev: 1.5.5 hooks: - id: cpplint # We don't lint all C files because we don't want to lint any that are built @@ -57,7 +57,7 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v2.12.0 + rev: v2.18.3 hooks: - id: pyupgrade args: [--py37-plus] @@ -72,7 +72,7 @@ repos: types: [text] # overwrite types: [rst] types_or: [python, rst] - repo: https://github.com/asottile/yesqa - rev: v1.2.2 + rev: v1.2.3 hooks: - id: yesqa additional_dependencies: diff --git a/doc/sphinxext/announce.py b/doc/sphinxext/announce.py index 2ec0b515ea95c..b0b430ed6a866 100755 --- a/doc/sphinxext/announce.py +++ b/doc/sphinxext/announce.py @@ -54,7 +54,7 @@ def get_authors(revision_range): pat = "^.*\\t(.*)$" - lst_release, cur_release = [r.strip() for r in revision_range.split("..")] + lst_release, cur_release = (r.strip() for r in revision_range.split("..")) if "|" in cur_release: # e.g. v1.0.1|HEAD @@ -119,7 +119,7 @@ def get_pull_requests(repo, revision_range): def build_components(revision_range, heading="Contributors"): - lst_release, cur_release = [r.strip() for r in revision_range.split("..")] + lst_release, cur_release = (r.strip() for r in revision_range.split("..")) authors = get_authors(revision_range) return { diff --git a/pandas/_config/config.py b/pandas/_config/config.py index 455f800073c15..37f5a5730439d 100644 --- a/pandas/_config/config.py +++ b/pandas/_config/config.py @@ -157,7 +157,7 @@ def _describe_option(pat: str = "", _print_desc: bool = True): if len(keys) == 0: raise OptionError("No such keys(s)") - s = "\n".join([_build_option_description(k) for k in keys]) + s = "\n".join(_build_option_description(k) for k in keys) if _print_desc: print(s) diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index be9eeb64bc35d..c05130278f75b 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -1475,7 +1475,7 @@ def get_join_indexers( for n in range(len(left_keys)) ) zipped = zip(*mapped) - llab, rlab, shape = [list(x) for x in zipped] + llab, rlab, shape = (list(x) for x in zipped) # get flat i8 keys from label lists lkey, rkey = _get_join_keys(llab, rlab, shape, sort) @@ -1985,7 +1985,7 @@ def _get_multiindex_indexer( for n in range(index.nlevels) ) zipped = zip(*mapped) - rcodes, lcodes, shape = [list(x) for x in zipped] + rcodes, lcodes, shape = (list(x) for x in zipped) if sort: rcodes = list(map(np.take, rcodes, index.codes)) else: diff --git a/pandas/core/reshape/tile.py b/pandas/core/reshape/tile.py index 7b9c3883d74e3..64daf2542e15a 100644 --- a/pandas/core/reshape/tile.py +++ b/pandas/core/reshape/tile.py @@ -250,7 +250,7 @@ def cut( raise ValueError("Cannot cut empty array") rng = (nanops.nanmin(x), nanops.nanmax(x)) - mn, mx = [mi + 0.0 for mi in rng] + mn, mx = (mi + 0.0 for mi in rng) if np.isinf(mn) or np.isinf(mx): # GH 24314 diff --git a/pandas/io/formats/excel.py b/pandas/io/formats/excel.py index 648df0ff2b6d9..c6ff4e2180893 100644 --- a/pandas/io/formats/excel.py +++ b/pandas/io/formats/excel.py @@ -773,7 +773,7 @@ def _generate_body(self, coloffset: int) -> Iterable[ExcelCell]: series = self.df.iloc[:, colidx] for i, val in enumerate(series): if styles is not None: - css = ";".join([a + ":" + str(v) for (a, v) in styles[i, colidx]]) + css = ";".join(a + ":" + str(v) for (a, v) in styles[i, colidx]) xlstyle = self.style_converter(css) yield ExcelCell(self.rowcounter + i, colidx + coloffset, val, xlstyle) diff --git a/pandas/io/formats/latex.py b/pandas/io/formats/latex.py index fce0814e979a4..476a3647207d6 100644 --- a/pandas/io/formats/latex.py +++ b/pandas/io/formats/latex.py @@ -361,7 +361,7 @@ def get_result(self) -> str: self.bottom_separator, self.env_end, ] - result = "\n".join([item for item in elements if item]) + result = "\n".join(item for item in elements if item) trailing_newline = "\n" result += trailing_newline return result @@ -530,13 +530,13 @@ def env_begin(self) -> str: f"\\begin{{longtable}}{self._position_macro}{{{self.column_format}}}" ) elements = [first_row, f"{self._caption_and_label()}"] - return "\n".join([item for item in elements if item]) + return "\n".join(item for item in elements if item) def _caption_and_label(self) -> str: if self.caption or self.label: double_backslash = "\\\\" elements = [f"{self._caption_macro}", f"{self._label_macro}"] - caption_and_label = "\n".join([item for item in elements if item]) + caption_and_label = "\n".join(item for item in elements if item) caption_and_label += double_backslash return caption_and_label else: @@ -614,7 +614,7 @@ def env_begin(self) -> str: f"{self._label_macro}", f"\\begin{{tabular}}{{{self.column_format}}}", ] - return "\n".join([item for item in elements if item]) + return "\n".join(item for item in elements if item) @property def bottom_separator(self) -> str: diff --git a/pandas/io/html.py b/pandas/io/html.py index 43584e2cecfc4..0a91d065379cb 100644 --- a/pandas/io/html.py +++ b/pandas/io/html.py @@ -627,7 +627,7 @@ def _build_xpath_expr(attrs) -> str: if "class_" in attrs: attrs["class"] = attrs.pop("class_") - s = " and ".join([f"@{k}={repr(v)}" for k, v in attrs.items()]) + s = " and ".join(f"@{k}={repr(v)}" for k, v in attrs.items()) return f"[{s}]" diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index d3d5d1b851cf7..b32eb9e308780 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -3513,7 +3513,7 @@ def validate_version(self, where=None): """ are we trying to operate on an old version? """ if where is not None: if self.version[0] <= 0 and self.version[1] <= 10 and self.version[2] < 1: - ws = incompatibility_doc % ".".join([str(x) for x in self.version]) + ws = incompatibility_doc % ".".join(str(x) for x in self.version) warnings.warn(ws, IncompatibilityWarning) def validate_min_itemsize(self, min_itemsize): diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index 49a1dc8bbb21c..103489e4abe98 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -126,7 +126,7 @@ def finalize(self, other, method=None, **kwargs): for name in self._metadata: if method == "concat": value = "+".join( - [getattr(o, name) for o in other.objs if getattr(o, name, None)] + getattr(o, name) for o in other.objs if getattr(o, name, None) ) object.__setattr__(self, name, value) else: diff --git a/pandas/tests/generic/test_series.py b/pandas/tests/generic/test_series.py index 6e5cb3add43df..755081349170d 100644 --- a/pandas/tests/generic/test_series.py +++ b/pandas/tests/generic/test_series.py @@ -130,7 +130,7 @@ def finalize(self, other, method=None, **kwargs): for name in self._metadata: if method == "concat" and name == "filename": value = "+".join( - [getattr(o, name) for o in other.objs if getattr(o, name, None)] + getattr(o, name) for o in other.objs if getattr(o, name, None) ) object.__setattr__(self, name, value) else: diff --git a/pandas/tests/io/parser/test_c_parser_only.py b/pandas/tests/io/parser/test_c_parser_only.py index 044af57f49240..5d1fa426ff24c 100644 --- a/pandas/tests/io/parser/test_c_parser_only.py +++ b/pandas/tests/io/parser/test_c_parser_only.py @@ -434,10 +434,10 @@ def test_internal_null_byte(c_parser_only): def test_read_nrows_large(c_parser_only): # gh-7626 - Read only nrows of data in for large inputs (>262144b) parser = c_parser_only - header_narrow = "\t".join(["COL_HEADER_" + str(i) for i in range(10)]) + "\n" - data_narrow = "\t".join(["somedatasomedatasomedata1" for _ in range(10)]) + "\n" - header_wide = "\t".join(["COL_HEADER_" + str(i) for i in range(15)]) + "\n" - data_wide = "\t".join(["somedatasomedatasomedata2" for _ in range(15)]) + "\n" + header_narrow = "\t".join("COL_HEADER_" + str(i) for i in range(10)) + "\n" + data_narrow = "\t".join("somedatasomedatasomedata1" for _ in range(10)) + "\n" + header_wide = "\t".join("COL_HEADER_" + str(i) for i in range(15)) + "\n" + data_wide = "\t".join("somedatasomedatasomedata2" for _ in range(15)) + "\n" test_input = header_narrow + data_narrow * 1050 + header_wide + data_wide * 2 df = parser.read_csv(StringIO(test_input), sep="\t", nrows=1010) @@ -565,7 +565,7 @@ def test_bytes_exceed_2gb(c_parser_only): if parser.low_memory: pytest.skip("not a high_memory test") - csv = StringIO("strings\n" + "\n".join(["x" * (1 << 20) for _ in range(2100)])) + csv = StringIO("strings\n" + "\n".join("x" * (1 << 20) for _ in range(2100))) df = parser.read_csv(csv) assert not df.empty diff --git a/pandas/tests/io/parser/test_multi_thread.py b/pandas/tests/io/parser/test_multi_thread.py index 123dce2048a44..981d1d438c3b0 100644 --- a/pandas/tests/io/parser/test_multi_thread.py +++ b/pandas/tests/io/parser/test_multi_thread.py @@ -44,7 +44,7 @@ def test_multi_thread_string_io_read_csv(all_parsers): num_files = 100 bytes_to_df = [ - "\n".join([f"{i:d},{i:d},{i:d}" for i in range(max_row_range)]).encode() + "\n".join(f"{i:d},{i:d},{i:d}" for i in range(max_row_range)).encode() for _ in range(num_files) ] diff --git a/pandas/tests/io/parser/test_skiprows.py b/pandas/tests/io/parser/test_skiprows.py index 0735f60fabbf6..62650b4ef42a3 100644 --- a/pandas/tests/io/parser/test_skiprows.py +++ b/pandas/tests/io/parser/test_skiprows.py @@ -49,10 +49,10 @@ def test_deep_skip_rows(all_parsers): # see gh-4382 parser = all_parsers data = "a,b,c\n" + "\n".join( - [",".join([str(i), str(i + 1), str(i + 2)]) for i in range(10)] + ",".join([str(i), str(i + 1), str(i + 2)]) for i in range(10) ) condensed_data = "a,b,c\n" + "\n".join( - [",".join([str(i), str(i + 1), str(i + 2)]) for i in [0, 1, 2, 3, 4, 6, 8, 9]] + ",".join([str(i), str(i + 1), str(i + 2)]) for i in [0, 1, 2, 3, 4, 6, 8, 9] ) result = parser.read_csv(StringIO(data), skiprows=[6, 8]) diff --git a/pandas/tests/reshape/test_util.py b/pandas/tests/reshape/test_util.py index 890562712f3b7..1ebe96a8b5a8d 100644 --- a/pandas/tests/reshape/test_util.py +++ b/pandas/tests/reshape/test_util.py @@ -22,7 +22,7 @@ def test_datetimeindex(self): # regression test for GitHub issue #6439 # make sure that the ordering on datetimeindex is consistent x = date_range("2000-01-01", periods=2) - result1, result2 = [Index(y).day for y in cartesian_product([x, x])] + result1, result2 = (Index(y).day for y in cartesian_product([x, x])) expected1 = Index([1, 1, 2, 2]) expected2 = Index([1, 2, 1, 2]) tm.assert_index_equal(result1, expected1) diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index c540c0e1c6721..0cbe5d8ff43b9 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -245,7 +245,7 @@ def _format_argument_list(allow_args: list[str]): return f" except for the argument '{allow_args[0]}'" else: last = allow_args[-1] - args = ", ".join(["'" + x + "'" for x in allow_args[:-1]]) + args = ", ".join("'" + x + "'" for x in allow_args[:-1]) return f" except for the arguments {args} and '{last}'" @@ -385,12 +385,10 @@ def decorator(decorated: F) -> F: # formatting templates and concatenating docstring decorated.__doc__ = "".join( - [ - component.format(**params) - if isinstance(component, str) - else dedent(component.__doc__ or "") - for component in docstring_components - ] + component.format(**params) + if isinstance(component, str) + else dedent(component.__doc__ or "") + for component in docstring_components ) # error: "F" has no attribute "_docstring_components"