Skip to content

Commit e84a7f7

Browse files
[pre-commit.ci] pre-commit autoupdate (#60840)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.4](astral-sh/ruff-pre-commit@v0.8.6...v0.9.4) - [github.com/codespell-project/codespell: v2.3.0 → v2.4.1](codespell-project/codespell@v2.3.0...v2.4.1) - [github.com/PyCQA/isort: 5.13.2 → 6.0.0](PyCQA/isort@5.13.2...6.0.0) - [github.com/pre-commit/mirrors-clang-format: v19.1.6 → v19.1.7](pre-commit/mirrors-clang-format@v19.1.6...v19.1.7) - [github.com/trim21/pre-commit-mirror-meson: v1.6.1 → v1.7.0](trim21/pre-commit-mirror-meson@v1.6.1...v1.7.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address ruff/codespell failures * Run ruff again --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent e58bf26 commit e84a7f7

File tree

90 files changed

+165
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+165
-260
lines changed

.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
skip: [pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.8.6
22+
rev: v0.9.4
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]
@@ -41,7 +41,7 @@ repos:
4141
pass_filenames: true
4242
require_serial: false
4343
- repo: https://github.com/codespell-project/codespell
44-
rev: v2.3.0
44+
rev: v2.4.1
4545
hooks:
4646
- id: codespell
4747
types_or: [python, rst, markdown, cython, c]
@@ -70,7 +70,7 @@ repos:
7070
- id: trailing-whitespace
7171
args: [--markdown-linebreak-ext=md]
7272
- repo: https://github.com/PyCQA/isort
73-
rev: 5.13.2
73+
rev: 6.0.0
7474
hooks:
7575
- id: isort
7676
- repo: https://github.com/asottile/pyupgrade
@@ -95,14 +95,14 @@ repos:
9595
- id: sphinx-lint
9696
args: ["--enable", "all", "--disable", "line-too-long"]
9797
- repo: https://github.com/pre-commit/mirrors-clang-format
98-
rev: v19.1.6
98+
rev: v19.1.7
9999
hooks:
100100
- id: clang-format
101101
files: ^pandas/_libs/src|^pandas/_libs/include
102102
args: [-i]
103103
types_or: [c, c++]
104104
- repo: https://github.com/trim21/pre-commit-mirror-meson
105-
rev: v1.6.1
105+
rev: v1.7.0
106106
hooks:
107107
- id: meson-fmt
108108
args: ['--inplace']

asv_bench/benchmarks/io/style.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Render:
1313
def setup(self, cols, rows):
1414
self.df = DataFrame(
1515
np.random.randn(rows, cols),
16-
columns=[f"float_{i+1}" for i in range(cols)],
17-
index=[f"row_{i+1}" for i in range(rows)],
16+
columns=[f"float_{i + 1}" for i in range(cols)],
17+
index=[f"row_{i + 1}" for i in range(rows)],
1818
)
1919

2020
def time_apply_render(self, cols, rows):

doc/make.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ def latex(self, force=False):
260260
for i in range(3):
261261
self._run_os("pdflatex", "-interaction=nonstopmode", "pandas.tex")
262262
raise SystemExit(
263-
"You should check the file "
264-
'"build/latex/pandas.pdf" for problems.'
263+
'You should check the file "build/latex/pandas.pdf" for problems.'
265264
)
266265
self._run_os("make")
267266
return ret_code
@@ -343,8 +342,7 @@ def main():
343342
dest="verbosity",
344343
default=0,
345344
help=(
346-
"increase verbosity (can be repeated), "
347-
"passed to the sphinx build command"
345+
"increase verbosity (can be repeated), passed to the sphinx build command"
348346
),
349347
)
350348
argparser.add_argument(

doc/source/user_guide/style.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@
12881288
"outputs": [],
12891289
"source": [
12901290
"df2.loc[:4].style.highlight_max(\n",
1291-
" axis=1, props=(\"color:white; \" \"font-weight:bold; \" \"background-color:darkblue;\")\n",
1291+
" axis=1, props=(\"color:white; font-weight:bold; background-color:darkblue;\")\n",
12921292
")"
12931293
]
12941294
},

pandas/core/apply.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,7 @@ def reconstruct_func(
16451645
# GH 28426 will raise error if duplicated function names are used and
16461646
# there is no reassigned name
16471647
raise SpecificationError(
1648-
"Function names must be unique if there is no new column names "
1649-
"assigned"
1648+
"Function names must be unique if there is no new column names assigned"
16501649
)
16511650
if func is None:
16521651
# nicer error message

pandas/core/arrays/base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1791,9 +1791,11 @@ def take(self, indices, allow_fill=False, fill_value=None):
17911791
# type for the array, to the physical storage type for
17921792
# the data, before passing to take.
17931793
1794-
result = take(data, indices, fill_value=fill_value, allow_fill=allow_fill)
1794+
result = take(
1795+
data, indices, fill_value=fill_value, allow_fill=allow_fill
1796+
)
17951797
return self._from_sequence(result, dtype=self.dtype)
1796-
""" # noqa: E501
1798+
"""
17971799
# Implementer note: The `fill_value` parameter should be a user-facing
17981800
# value, an instance of self.dtype.type. When passed `fill_value=None`,
17991801
# the default of `self.dtype.na_value` should be used.

pandas/core/arrays/datetimes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2707,8 +2707,7 @@ def _maybe_infer_tz(tz: tzinfo | None, inferred_tz: tzinfo | None) -> tzinfo | N
27072707
pass
27082708
elif not timezones.tz_compare(tz, inferred_tz):
27092709
raise TypeError(
2710-
f"data is already tz-aware {inferred_tz}, unable to "
2711-
f"set specified tz: {tz}"
2710+
f"data is already tz-aware {inferred_tz}, unable to set specified tz: {tz}"
27122711
)
27132712
return tz
27142713

pandas/core/computation/eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def eval(
204204
205205
By default, with the numexpr engine, the following operations are supported:
206206
207-
- Arthimetic operations: ``+``, ``-``, ``*``, ``/``, ``**``, ``%``
207+
- Arithmetic operations: ``+``, ``-``, ``*``, ``/``, ``**``, ``%``
208208
- Boolean operations: ``|`` (or), ``&`` (and), and ``~`` (not)
209209
- Comparison operators: ``<``, ``<=``, ``==``, ``!=``, ``>=``, ``>``
210210

pandas/core/computation/expr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def visit_Call(self, node, side=None, **kwargs):
698698
if not isinstance(key, ast.keyword):
699699
# error: "expr" has no attribute "id"
700700
raise ValueError(
701-
"keyword error in function call " f"'{node.func.id}'" # type: ignore[attr-defined]
701+
f"keyword error in function call '{node.func.id}'" # type: ignore[attr-defined]
702702
)
703703

704704
if key.arg:

pandas/core/computation/ops.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ def __init__(self, op: Literal["+", "-", "~", "not"], operand) -> None:
512512
self.func = _unary_ops_dict[op]
513513
except KeyError as err:
514514
raise ValueError(
515-
f"Invalid unary operator {op!r}, "
516-
f"valid operators are {UNARY_OPS_SYMS}"
515+
f"Invalid unary operator {op!r}, valid operators are {UNARY_OPS_SYMS}"
517516
) from err
518517

519518
def __call__(self, env) -> MathCall:

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n
16511651
# (test_constructor_coercion_signed_to_unsigned) so safe to ignore.
16521652
warnings.filterwarnings(
16531653
"ignore",
1654-
"NumPy will stop allowing conversion of " "out-of-bound Python int",
1654+
"NumPy will stop allowing conversion of out-of-bound Python int",
16551655
DeprecationWarning,
16561656
)
16571657
casted = np.asarray(arr, dtype=dtype)

pandas/core/dtypes/dtypes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,7 @@ def update_dtype(self, dtype: str_type | CategoricalDtype) -> CategoricalDtype:
605605
return self
606606
elif not self.is_dtype(dtype):
607607
raise ValueError(
608-
f"a CategoricalDtype must be passed to perform an update, "
609-
f"got {dtype!r}"
608+
f"a CategoricalDtype must be passed to perform an update, got {dtype!r}"
610609
)
611610
else:
612611
# from here on, dtype is a CategoricalDtype

pandas/core/generic.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5537,8 +5537,7 @@ def filter(
55375537
nkw = common.count_not_none(items, like, regex)
55385538
if nkw > 1:
55395539
raise TypeError(
5540-
"Keyword arguments `items`, `like`, or `regex` "
5541-
"are mutually exclusive"
5540+
"Keyword arguments `items`, `like`, or `regex` are mutually exclusive"
55425541
)
55435542

55445543
if axis is None:

pandas/core/groupby/groupby.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2632,8 +2632,7 @@ def _value_counts(
26322632
doesnt_exist = subsetted - unique_cols
26332633
if doesnt_exist:
26342634
raise ValueError(
2635-
f"Keys {doesnt_exist} in subset do not "
2636-
f"exist in the DataFrame."
2635+
f"Keys {doesnt_exist} in subset do not exist in the DataFrame."
26372636
)
26382637
else:
26392638
subsetted = unique_cols

pandas/core/groupby/grouper.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,7 @@ def __init__(
516516
):
517517
grper = pprint_thing(grouping_vector)
518518
errmsg = (
519-
"Grouper result violates len(labels) == "
520-
f"len(data)\nresult: {grper}"
519+
f"Grouper result violates len(labels) == len(data)\nresult: {grper}"
521520
)
522521
raise AssertionError(errmsg)
523522

pandas/core/indexers/objects.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ def get_window_bounds(
478478
)
479479
start = start.astype(np.int64)
480480
end = end.astype(np.int64)
481-
assert len(start) == len(
482-
end
483-
), "these should be equal in length from get_window_bounds"
481+
assert len(start) == len(end), (
482+
"these should be equal in length from get_window_bounds"
483+
)
484484
# Cannot use groupby_indices as they might not be monotonic with the object
485485
# we're rolling over
486486
window_indices = np.arange(

pandas/core/indexing.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,7 @@ def _validate_tuple_indexer(self, key: tuple) -> tuple:
975975
self._validate_key(k, i)
976976
except ValueError as err:
977977
raise ValueError(
978-
"Location based indexing can only have "
979-
f"[{self._valid_types}] types"
978+
f"Location based indexing can only have [{self._valid_types}] types"
980979
) from err
981980
return key
982981

@@ -1589,8 +1588,7 @@ def _validate_key(self, key, axis: AxisInt) -> None:
15891588
"is not available"
15901589
)
15911590
raise ValueError(
1592-
"iLocation based boolean indexing cannot use "
1593-
"an indexable as a mask"
1591+
"iLocation based boolean indexing cannot use an indexable as a mask"
15941592
)
15951593
return
15961594

@@ -1994,8 +1992,7 @@ def _setitem_with_indexer_split_path(self, indexer, value, name: str):
19941992
return self._setitem_with_indexer((pi, info_axis[0]), value[0])
19951993

19961994
raise ValueError(
1997-
"Must have equal len keys and value "
1998-
"when setting with an iterable"
1995+
"Must have equal len keys and value when setting with an iterable"
19991996
)
20001997

20011998
elif lplane_indexer == 0 and len(value) == len(self.obj.index):
@@ -2023,8 +2020,7 @@ def _setitem_with_indexer_split_path(self, indexer, value, name: str):
20232020

20242021
else:
20252022
raise ValueError(
2026-
"Must have equal len keys and value "
2027-
"when setting with an iterable"
2023+
"Must have equal len keys and value when setting with an iterable"
20282024
)
20292025

20302026
else:

pandas/core/interchange/buffer.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def __init__(self, x: np.ndarray, allow_copy: bool = True) -> None:
3131
x = x.copy()
3232
else:
3333
raise RuntimeError(
34-
"Exports cannot be zero-copy in the case "
35-
"of a non-contiguous buffer"
34+
"Exports cannot be zero-copy in the case of a non-contiguous buffer"
3635
)
3736

3837
# Store the numpy array in which the data resides as a private

pandas/core/internals/blocks.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2264,8 +2264,7 @@ def check_ndim(values, placement: BlockPlacement, ndim: int) -> None:
22642264
if values.ndim > ndim:
22652265
# Check for both np.ndarray and ExtensionArray
22662266
raise ValueError(
2267-
"Wrong number of dimensions. "
2268-
f"values.ndim > ndim [{values.ndim} > {ndim}]"
2267+
f"Wrong number of dimensions. values.ndim > ndim [{values.ndim} > {ndim}]"
22692268
)
22702269

22712270
if not is_1d_only_ea_dtype(values.dtype):

pandas/core/internals/construction.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,7 @@ def _validate_or_indexify_columns(
907907
if not is_mi_list and len(columns) != len(content): # pragma: no cover
908908
# caller's responsibility to check for this...
909909
raise AssertionError(
910-
f"{len(columns)} columns passed, passed data had "
911-
f"{len(content)} columns"
910+
f"{len(columns)} columns passed, passed data had {len(content)} columns"
912911
)
913912
if is_mi_list:
914913
# check if nested list column, length of each sub-list should be equal

pandas/core/ops/array_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _masked_arith_op(x: np.ndarray, y, op) -> np.ndarray:
164164
else:
165165
if not is_scalar(y):
166166
raise TypeError(
167-
f"Cannot broadcast np.ndarray with operand of type { type(y) }"
167+
f"Cannot broadcast np.ndarray with operand of type {type(y)}"
168168
)
169169

170170
# mask is only meaningful for x

pandas/core/reshape/encoding.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ def from_dummies(
495495

496496
if col_isna_mask.any():
497497
raise ValueError(
498-
"Dummy DataFrame contains NA value in column: "
499-
f"'{col_isna_mask.idxmax()}'"
498+
f"Dummy DataFrame contains NA value in column: '{col_isna_mask.idxmax()}'"
500499
)
501500

502501
# index data with a list of all columns that are dummies

pandas/core/reshape/merge.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1929,9 +1929,9 @@ def get_join_indexers(
19291929
np.ndarray[np.intp] or None
19301930
Indexer into the right_keys.
19311931
"""
1932-
assert len(left_keys) == len(
1933-
right_keys
1934-
), "left_keys and right_keys must be the same length"
1932+
assert len(left_keys) == len(right_keys), (
1933+
"left_keys and right_keys must be the same length"
1934+
)
19351935

19361936
# fast-path for empty left/right
19371937
left_n = len(left_keys[0])

pandas/core/tools/datetimes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def should_cache(
192192
else:
193193
check_count = 500
194194
else:
195-
assert (
196-
0 <= check_count <= len(arg)
197-
), "check_count must be in next bounds: [0; len(arg)]"
195+
assert 0 <= check_count <= len(arg), (
196+
"check_count must be in next bounds: [0; len(arg)]"
197+
)
198198
if check_count == 0:
199199
return False
200200

pandas/io/excel/_odswriter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def _process_style(self, style: dict[str, Any] | None) -> str | None:
270270
style_key = json.dumps(style)
271271
if style_key in self._style_dict:
272272
return self._style_dict[style_key]
273-
name = f"pd{len(self._style_dict)+1}"
273+
name = f"pd{len(self._style_dict) + 1}"
274274
self._style_dict[style_key] = name
275275
odf_style = Style(name=name, family="table-cell")
276276
if "font" in style:

pandas/io/formats/printing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ def format_object_summary(
336336

337337
if indent_for_name:
338338
name_len = len(name)
339-
space1 = f'\n{(" " * (name_len + 1))}'
340-
space2 = f'\n{(" " * (name_len + 2))}'
339+
space1 = f"\n{(' ' * (name_len + 1))}"
340+
space2 = f"\n{(' ' * (name_len + 2))}"
341341
else:
342342
space1 = "\n"
343343
space2 = "\n " # space for the opening '['

pandas/io/formats/style.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,7 @@ def set_sticky(
25882588
for i, level in enumerate(levels_):
25892589
styles.append(
25902590
{
2591-
"selector": f"thead tr:nth-child({level+1}) th",
2591+
"selector": f"thead tr:nth-child({level + 1}) th",
25922592
"props": props
25932593
+ (
25942594
f"top:{i * pixel_size}px; height:{pixel_size}px; "
@@ -2599,7 +2599,7 @@ def set_sticky(
25992599
if not all(name is None for name in self.index.names):
26002600
styles.append(
26012601
{
2602-
"selector": f"thead tr:nth-child({obj.nlevels+1}) th",
2602+
"selector": f"thead tr:nth-child({obj.nlevels + 1}) th",
26032603
"props": props
26042604
+ (
26052605
f"top:{(len(levels_)) * pixel_size}px; "
@@ -2619,7 +2619,7 @@ def set_sticky(
26192619
styles.extend(
26202620
[
26212621
{
2622-
"selector": f"thead tr th:nth-child({level+1})",
2622+
"selector": f"thead tr th:nth-child({level + 1})",
26232623
"props": props_ + "z-index:3 !important;",
26242624
},
26252625
{
@@ -4214,8 +4214,10 @@ def css_bar(start: float, end: float, color: str) -> str:
42144214
if end > start:
42154215
cell_css += "background: linear-gradient(90deg,"
42164216
if start > 0:
4217-
cell_css += f" transparent {start*100:.1f}%, {color} {start*100:.1f}%,"
4218-
cell_css += f" {color} {end*100:.1f}%, transparent {end*100:.1f}%)"
4217+
cell_css += (
4218+
f" transparent {start * 100:.1f}%, {color} {start * 100:.1f}%,"
4219+
)
4220+
cell_css += f" {color} {end * 100:.1f}%, transparent {end * 100:.1f}%)"
42194221
return cell_css
42204222

42214223
def css_calc(x, left: float, right: float, align: str, color: str | list | tuple):

0 commit comments

Comments
 (0)