Skip to content

Commit cc4f585

Browse files
authored
STY: Bump pre-commit checks (pandas-dev#61246)
* Bump pre-commit version, bump clang-format and meson * Fix type checking abbreviation * Bump to 0.11.4 * Put minimum version at 4 * Change misc to arg-type
1 parent 1bcdfd0 commit cc4f585

24 files changed

+42
-42
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
minimum_pre_commit_version: 2.15.0
1+
minimum_pre_commit_version: 4.0.0
22
exclude: ^LICENSES/|\.(html|csv|svg)$
33
# reserve "manual" for relatively slow hooks which we still want to run in CI
44
default_stages: [
@@ -19,13 +19,13 @@ ci:
1919
skip: [pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.9.9
22+
rev: v0.11.4
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]
2626
exclude: ^pandas/tests/frame/test_query_eval.py
2727
- id: ruff
28-
# TODO: remove autofixe-only rules when they are checked by ruff
28+
# TODO: remove autofix only rules when they are checked by ruff
2929
name: ruff-selected-autofixes
3030
alias: ruff-selected-autofixes
3131
files: ^pandas
@@ -34,7 +34,7 @@ repos:
3434
- id: ruff-format
3535
exclude: ^scripts|^pandas/tests/frame/test_query_eval.py
3636
- repo: https://github.com/jendrikseipp/vulture
37-
rev: 'v2.14'
37+
rev: v2.14
3838
hooks:
3939
- id: vulture
4040
entry: python scripts/run_vulture.py
@@ -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.7
98+
rev: v20.1.0
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.7.0
105+
rev: v1.7.2
106106
hooks:
107107
- id: meson-fmt
108108
args: ['--inplace']

asv_bench/benchmarks/frame_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def setup(self):
517517
self.df = DataFrame(np.random.randn(1000, 100))
518518

519519
self.s = Series(np.arange(1028.0))
520-
self.df2 = DataFrame({i: self.s for i in range(1028)})
520+
self.df2 = DataFrame(dict.fromkeys(range(1028), self.s))
521521
self.df3 = DataFrame(np.random.randn(1000, 3), columns=list("ABC"))
522522

523523
def time_apply_user_func(self):

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ dependencies:
8080
- flake8=7.1.0 # run in subprocess over docstring examples
8181
- mypy=1.13.0 # pre-commit uses locally installed mypy
8282
- tokenize-rt # scripts/check_for_inconsistent_pandas_namespace.py
83-
- pre-commit>=4.0.1
83+
- pre-commit>=4.2.0
8484

8585
# documentation
8686
- gitpython # obtain contributors from git for whatsnew

pandas/_libs/tslibs/timedeltas.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from typing import (
33
ClassVar,
44
Literal,
55
TypeAlias,
6-
TypeVar,
76
overload,
87
)
98

@@ -60,7 +59,6 @@ UnitChoices: TypeAlias = Literal[
6059
"nanos",
6160
"nanosecond",
6261
]
63-
_S = TypeVar("_S", bound=timedelta)
6462

6563
def get_unit_for_round(freq, creso: int) -> int: ...
6664
def disallow_ambiguous_unit(unit: str | None) -> None: ...
@@ -95,11 +93,11 @@ class Timedelta(timedelta):
9593
_value: int # np.int64
9694
# error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
9795
def __new__( # type: ignore[misc]
98-
cls: type[_S],
96+
cls: type[Self],
9997
value=...,
10098
unit: str | None = ...,
10199
**kwargs: float | np.integer | np.floating,
102-
) -> _S | NaTType: ...
100+
) -> Self | NaTType: ...
103101
@classmethod
104102
def _from_value_and_reso(cls, value: np.int64, reso: int) -> Timedelta: ...
105103
@property

pandas/core/apply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def transform(self) -> DataFrame | Series:
327327
if is_series:
328328
func = {com.get_callable_name(v) or v: v for v in func}
329329
else:
330-
func = {col: func for col in obj}
330+
func = dict.fromkeys(obj, func)
331331

332332
if is_dict_like(func):
333333
func = cast(AggFuncTypeDict, func)

pandas/core/arrays/string_arrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def isin(self, values: ArrayLike) -> npt.NDArray[np.bool_]:
281281
]
282282

283283
# short-circuit to return all False array.
284-
if not len(value_set):
284+
if not value_set:
285285
return np.zeros(len(self), dtype=bool)
286286

287287
result = pc.is_in(

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9705,7 +9705,7 @@ def _where(
97059705
# CoW: Make sure reference is not kept alive
97069706
if cond.ndim == 1 and self.ndim == 2:
97079707
cond = cond._constructor_expanddim(
9708-
{i: cond for i in range(len(self.columns))},
9708+
dict.fromkeys(range(len(self.columns)), cond),
97099709
copy=False,
97109710
)
97119711
cond.columns = self.columns

pandas/core/groupby/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@ def _apply_to_column_groupbys(self, func) -> DataFrame:
25052505
)
25062506
results = [func(sgb) for sgb in sgbs]
25072507

2508-
if not len(results):
2508+
if not results:
25092509
# concat would raise
25102510
res_df = DataFrame([], columns=columns, index=self._grouper.result_index)
25112511
else:

pandas/core/groupby/groupby.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5175,8 +5175,8 @@ def diff(
51755175
shifted = shifted.astype("float32")
51765176
else:
51775177
to_coerce = [c for c, dtype in obj.dtypes.items() if dtype in dtypes_to_f32]
5178-
if len(to_coerce):
5179-
shifted = shifted.astype({c: "float32" for c in to_coerce})
5178+
if to_coerce:
5179+
shifted = shifted.astype(dict.fromkeys(to_coerce, "float32"))
51805180

51815181
return obj - shifted
51825182

pandas/core/internals/blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def replace_list(
805805
for x, y in zip(src_list, dest_list)
806806
if (self._can_hold_element(x) or (self.dtype == "string" and is_re(x)))
807807
]
808-
if not len(pairs):
808+
if not pairs:
809809
return [self.copy(deep=False)]
810810

811811
src_len = len(pairs) - 1

0 commit comments

Comments
 (0)