Skip to content

⬆️ UPGRADE: Autoupdate pre-commit config #41160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinxext/announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions pandas/io/formats/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]"


Expand Down
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/generic/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/generic/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/io/parser/test_c_parser_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/parser/test_multi_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/parser/test_skiprows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/reshape/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"


Expand Down Expand Up @@ -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"
Expand Down