Skip to content

Commit a32a328

Browse files
authored
STYL: replace autotyping with ruff's ANN autofixes (#54260)
* STYL: replace autotyping with ruff's ANN autofixes * ignore vendored clipboard file from ruff * comment to remove it in the future * alias
1 parent c5b0a00 commit a32a328

File tree

12 files changed

+14
-85
lines changed

12 files changed

+14
-85
lines changed

.libcst.codemod.yaml

-18
This file was deleted.

.pre-commit-config.yaml

+5-11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ repos:
2525
hooks:
2626
- id: ruff
2727
args: [--exit-non-zero-on-fix]
28+
- id: ruff
29+
# TODO: remove autofixe-only rules when they are checked by ruff
30+
name: ruff-selected-autofixes
31+
alias: ruff-selected-autofixes
32+
args: [--select, "ANN001,ANN204", --fix-only, --exit-non-zero-on-fix]
2833
- repo: https://github.com/jendrikseipp/vulture
2934
rev: 'v2.7'
3035
hooks:
@@ -371,17 +376,6 @@ repos:
371376
/(__init__\.py)|(api\.py)|(_version\.py)|(testing\.py)|(conftest\.py)$
372377
|/tests/
373378
|/_testing/
374-
- id: autotyping
375-
name: autotyping
376-
entry: python -m scripts.run_autotyping
377-
types_or: [python, pyi]
378-
files: ^pandas
379-
exclude: ^(pandas/tests|pandas/_version.py|pandas/io/clipboard)
380-
language: python
381-
stages: [manual]
382-
additional_dependencies:
383-
- autotyping==23.3.0
384-
- libcst==0.4.9
385379
- id: check-test-naming
386380
name: check that test names start with 'test'
387381
entry: python -m scripts.check_test_naming

pandas/core/arrays/sparse/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def __array__(self, dtype: NpDtype | None = None) -> np.ndarray:
575575
out[self.sp_index.indices] = self.sp_values
576576
return out
577577

578-
def __setitem__(self, key, value):
578+
def __setitem__(self, key, value) -> None:
579579
# I suppose we could allow setting of non-fill_value elements.
580580
# TODO(SparseArray.__setitem__): remove special cases in
581581
# ExtensionBlock.where

pandas/core/arrays/string_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def _values_for_factorize(self):
401401
arr[mask] = None
402402
return arr, None
403403

404-
def __setitem__(self, key, value):
404+
def __setitem__(self, key, value) -> None:
405405
value = extract_array(value, extract_numpy=True)
406406
if isinstance(value, type(self)):
407407
# extract_array doesn't extract NumpyExtensionArray subclasses

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,7 @@ def isetitem(self, loc, value) -> None:
40314031
arraylike, refs = self._sanitize_column(value)
40324032
self._iset_item_mgr(loc, arraylike, inplace=False, refs=refs)
40334033

4034-
def __setitem__(self, key, value):
4034+
def __setitem__(self, key, value) -> None:
40354035
if not PYPY and using_copy_on_write():
40364036
if sys.getrefcount(self) <= 3:
40374037
warnings.warn(

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5329,7 +5329,7 @@ def __contains__(self, key: Any) -> bool:
53295329
__hash__: ClassVar[None] # type: ignore[assignment]
53305330

53315331
@final
5332-
def __setitem__(self, key, value):
5332+
def __setitem__(self, key, value) -> None:
53335333
raise TypeError("Index does not support mutable operations")
53345334

53355335
def __getitem__(self, key):

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ def __getitem__(self, key):
24862486

24872487
return super().__getitem__(key)
24882488

2489-
def __setitem__(self, key, value):
2489+
def __setitem__(self, key, value) -> None:
24902490
if self.ndim == 2 and not self._axes_are_unique:
24912491
# GH#33041 fall back to .loc
24922492
if not isinstance(key, tuple) or not all(is_scalar(x) for x in key):

pandas/tests/extension/date/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def __getitem__(self, item: PositionalIndexer):
148148
else:
149149
raise NotImplementedError("only ints are supported as indexes")
150150

151-
def __setitem__(self, key: int | slice | np.ndarray, value: Any):
151+
def __setitem__(self, key: int | slice | np.ndarray, value: Any) -> None:
152152
if not isinstance(key, int):
153153
raise NotImplementedError("only ints are supported as indexes")
154154

pandas/tests/extension/decimal/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def astype(self, dtype, copy=True):
190190

191191
return super().astype(dtype, copy=copy)
192192

193-
def __setitem__(self, key, value):
193+
def __setitem__(self, key, value) -> None:
194194
if is_list_like(value):
195195
if is_scalar(key):
196196
raise ValueError("setting an array element with a sequence.")

pandas/tests/extension/json/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __getitem__(self, item):
117117
# integer
118118
return type(self)([self.data[i] for i in item])
119119

120-
def __setitem__(self, key, value):
120+
def __setitem__(self, key, value) -> None:
121121
if isinstance(key, numbers.Integral):
122122
self.data[key] = value
123123
else:

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ exclude = [
349349
".eggs/*.py",
350350
# vendored files
351351
"pandas/util/version/*",
352+
"pandas/io/clipboard/__init__.py",
352353
# exclude asv benchmark environments from linting
353354
"env",
354355
]

scripts/run_autotyping.py

-48
This file was deleted.

0 commit comments

Comments
 (0)