Skip to content

Commit 15c21a2

Browse files
authored
Bump ruff to latest version (#57766)
* Bump ruff to latest version * Autoformat * Ignore conflicted error * Ignore false positive
1 parent 2d4305c commit 15c21a2

File tree

309 files changed

+814
-934
lines changed

Some content is hidden

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

309 files changed

+814
-934
lines changed

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
skip: [pylint, pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.1.13
22+
rev: v0.3.1
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]

Diff for: asv_bench/benchmarks/indexing.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
lower-level methods directly on Index and subclasses, see index_object.py,
44
indexing_engine.py, and index_cached.py
55
"""
6+
67
from datetime import datetime
78
import warnings
89

Diff for: asv_bench/benchmarks/libs.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
If a PR does not edit anything in _libs/, then it is unlikely that the
66
benchmarks will be affected.
77
"""
8+
89
import numpy as np
910

1011
from pandas._libs.lib import (

Diff for: asv_bench/benchmarks/package.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Benchmarks for pandas at the package-level.
33
"""
4+
45
import subprocess
56
import sys
67

Diff for: asv_bench/benchmarks/period.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Period benchmarks with non-tslibs dependencies. See
33
benchmarks.tslibs.period for benchmarks that rely only on tslibs.
44
"""
5+
56
from pandas import (
67
DataFrame,
78
Period,

Diff for: asv_bench/benchmarks/tslibs/offsets.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
offsets benchmarks that rely only on tslibs. See benchmarks.offset for
33
offsets benchmarks that rely on other parts of pandas.
44
"""
5+
56
from datetime import datetime
67

78
import numpy as np

Diff for: asv_bench/benchmarks/tslibs/resolution.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
df.loc[key] = (val.average, val.stdev)
1818
1919
"""
20+
2021
import numpy as np
2122

2223
try:

Diff for: asv_bench/benchmarks/tslibs/timedelta.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Timedelta benchmarks that rely only on tslibs. See benchmarks.timedeltas for
33
Timedelta benchmarks that rely on other parts of pandas.
44
"""
5+
56
import datetime
67

78
import numpy as np

Diff for: asv_bench/benchmarks/tslibs/tslib.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
val = %timeit -o tr.time_ints_to_pydatetime(box, size, tz)
1616
df.loc[key] = (val.average, val.stdev)
1717
"""
18+
1819
from datetime import (
1920
timedelta,
2021
timezone,

Diff for: doc/make.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
$ python make.py html
1212
$ python make.py latex
1313
"""
14+
1415
import argparse
1516
import csv
1617
import importlib

Diff for: pandas/_config/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importing `dates` and `display` ensures that keys needed by _libs
66
are initialized.
77
"""
8+
89
__all__ = [
910
"config",
1011
"detect_console_encoding",

Diff for: pandas/_config/config.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -688,15 +688,13 @@ def _build_option_description(k: str) -> str:
688688
@overload
689689
def pp_options_list(
690690
keys: Iterable[str], *, width: int = ..., _print: Literal[False] = ...
691-
) -> str:
692-
...
691+
) -> str: ...
693692

694693

695694
@overload
696695
def pp_options_list(
697696
keys: Iterable[str], *, width: int = ..., _print: Literal[True]
698-
) -> None:
699-
...
697+
) -> None: ...
700698

701699

702700
def pp_options_list(

Diff for: pandas/_config/dates.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
config for datetime formatting
33
"""
4+
45
from __future__ import annotations
56

67
from pandas._config import config as cf

Diff for: pandas/_config/localization.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Name `localization` is chosen to avoid overlap with builtin `locale` module.
55
"""
6+
67
from __future__ import annotations
78

89
from contextlib import contextmanager

Diff for: pandas/_testing/_hypothesis.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Hypothesis data generator helpers.
33
"""
4+
45
from datetime import datetime
56

67
from hypothesis import strategies as st

Diff for: pandas/_testing/compat.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Helpers for sharing tests between DataFrame/Series
33
"""
4+
45
from __future__ import annotations
56

67
from typing import TYPE_CHECKING

Diff for: pandas/_typing.py

+10-20
Original file line numberDiff line numberDiff line change
@@ -140,30 +140,22 @@
140140

141141
class SequenceNotStr(Protocol[_T_co]):
142142
@overload
143-
def __getitem__(self, index: SupportsIndex, /) -> _T_co:
144-
...
143+
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
145144

146145
@overload
147-
def __getitem__(self, index: slice, /) -> Sequence[_T_co]:
148-
...
146+
def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
149147

150-
def __contains__(self, value: object, /) -> bool:
151-
...
148+
def __contains__(self, value: object, /) -> bool: ...
152149

153-
def __len__(self) -> int:
154-
...
150+
def __len__(self) -> int: ...
155151

156-
def __iter__(self) -> Iterator[_T_co]:
157-
...
152+
def __iter__(self) -> Iterator[_T_co]: ...
158153

159-
def index(self, value: Any, start: int = ..., stop: int = ..., /) -> int:
160-
...
154+
def index(self, value: Any, start: int = ..., stop: int = ..., /) -> int: ...
161155

162-
def count(self, value: Any, /) -> int:
163-
...
156+
def count(self, value: Any, /) -> int: ...
164157

165-
def __reversed__(self) -> Iterator[_T_co]:
166-
...
158+
def __reversed__(self) -> Iterator[_T_co]: ...
167159

168160

169161
ListLike = Union[AnyArrayLike, SequenceNotStr, range]
@@ -317,13 +309,11 @@ def flush(self) -> Any:
317309

318310

319311
class ReadPickleBuffer(ReadBuffer[bytes], Protocol):
320-
def readline(self) -> bytes:
321-
...
312+
def readline(self) -> bytes: ...
322313

323314

324315
class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
325-
def truncate(self, size: int | None = ...) -> int:
326-
...
316+
def truncate(self, size: int | None = ...) -> int: ...
327317

328318

329319
class ReadCsvBuffer(ReadBuffer[AnyStr_co], Protocol):

Diff for: pandas/_version.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
358358
if verbose:
359359
fmt = "tag '%s' doesn't start with prefix '%s'"
360360
print(fmt % (full_tag, tag_prefix))
361-
pieces[
362-
"error"
363-
] = f"tag '{full_tag}' doesn't start with prefix '{tag_prefix}'"
361+
pieces["error"] = (
362+
f"tag '{full_tag}' doesn't start with prefix '{tag_prefix}'"
363+
)
364364
return pieces
365365
pieces["closest-tag"] = full_tag[len(tag_prefix) :]
366366

Diff for: pandas/api/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" public toolkit API """
1+
"""public toolkit API"""
2+
23
from pandas.api import (
34
extensions,
45
indexers,

Diff for: pandas/arrays/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
See :ref:`extending.extension-types` for more.
55
"""
6+
67
from pandas.core.arrays import (
78
ArrowExtensionArray,
89
ArrowStringArray,

Diff for: pandas/compat/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Other items:
88
* platform checker
99
"""
10+
1011
from __future__ import annotations
1112

1213
import os

Diff for: pandas/compat/_optional.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ def import_optional_dependency(
9191
min_version: str | None = ...,
9292
*,
9393
errors: Literal["raise"] = ...,
94-
) -> types.ModuleType:
95-
...
94+
) -> types.ModuleType: ...
9695

9796

9897
@overload
@@ -102,8 +101,7 @@ def import_optional_dependency(
102101
min_version: str | None = ...,
103102
*,
104103
errors: Literal["warn", "ignore"],
105-
) -> types.ModuleType | None:
106-
...
104+
) -> types.ModuleType | None: ...
107105

108106

109107
def import_optional_dependency(

Diff for: pandas/compat/numpy/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" support numpy compatibility across versions """
1+
"""support numpy compatibility across versions"""
2+
23
import warnings
34

45
import numpy as np

Diff for: pandas/compat/numpy/function.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
methods that are spread throughout the codebase. This module will make it
1616
easier to adjust to future upstream changes in the analogous numpy signatures.
1717
"""
18+
1819
from __future__ import annotations
1920

2021
from typing import (
@@ -179,13 +180,11 @@ def validate_argsort_with_ascending(ascending: bool | int | None, args, kwargs)
179180

180181

181182
@overload
182-
def validate_clip_with_axis(axis: ndarray, args, kwargs) -> None:
183-
...
183+
def validate_clip_with_axis(axis: ndarray, args, kwargs) -> None: ...
184184

185185

186186
@overload
187-
def validate_clip_with_axis(axis: AxisNoneT, args, kwargs) -> AxisNoneT:
188-
...
187+
def validate_clip_with_axis(axis: AxisNoneT, args, kwargs) -> AxisNoneT: ...
189188

190189

191190
def validate_clip_with_axis(

Diff for: pandas/compat/pickle_compat.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Pickle compatibility to pandas version 1.0
33
"""
4+
45
from __future__ import annotations
56

67
import contextlib

Diff for: pandas/compat/pyarrow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" support pyarrow compatibility across versions """
1+
"""support pyarrow compatibility across versions"""
22

33
from __future__ import annotations
44

Diff for: pandas/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Dtypes
1818
- Misc
1919
"""
20+
2021
from __future__ import annotations
2122

2223
from collections import abc

Diff for: pandas/core/_numba/kernels/mean_.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
Mirrors pandas/_libs/window/aggregation.pyx
88
"""
9+
910
from __future__ import annotations
1011

1112
from typing import TYPE_CHECKING

Diff for: pandas/core/_numba/kernels/min_max_.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
Mirrors pandas/_libs/window/aggregation.pyx
88
"""
9+
910
from __future__ import annotations
1011

1112
from typing import TYPE_CHECKING

Diff for: pandas/core/_numba/kernels/sum_.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
Mirrors pandas/_libs/window/aggregation.pyx
88
"""
9+
910
from __future__ import annotations
1011

1112
from typing import (

Diff for: pandas/core/_numba/kernels/var_.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
Mirrors pandas/_libs/window/aggregation.pyx
88
"""
9+
910
from __future__ import annotations
1011

1112
from typing import TYPE_CHECKING

Diff for: pandas/core/accessor.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
that can be mixed into or pinned onto other pandas classes.
55
66
"""
7+
78
from __future__ import annotations
89

910
from typing import (

Diff for: pandas/core/algorithms.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Generic data algorithms. This module is experimental at the moment and not
33
intended for public consumption
44
"""
5+
56
from __future__ import annotations
67

78
import decimal

Diff for: pandas/core/apply.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1300,9 +1300,10 @@ def apply_with_numba(self) -> dict[int, Any]:
13001300

13011301
# Convert from numba dict to regular dict
13021302
# Our isinstance checks in the df constructor don't pass for numbas typed dict
1303-
with set_numba_data(self.obj.index) as index, set_numba_data(
1304-
self.columns
1305-
) as columns:
1303+
with (
1304+
set_numba_data(self.obj.index) as index,
1305+
set_numba_data(self.columns) as columns,
1306+
):
13061307
res = dict(nb_func(self.values, columns, index))
13071308

13081309
return res

Diff for: pandas/core/array_algos/masked_reductions.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
masked_reductions.py is for reduction algorithms using a mask-based approach
33
for missing values.
44
"""
5+
56
from __future__ import annotations
67

78
from typing import (

Diff for: pandas/core/array_algos/putmask.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
EA-compatible analogue to np.putmask
33
"""
4+
45
from __future__ import annotations
56

67
from typing import (

Diff for: pandas/core/array_algos/replace.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Methods used by Block.replace and related methods.
33
"""
4+
45
from __future__ import annotations
56

67
import operator

0 commit comments

Comments
 (0)