Skip to content

Commit 5c68fce

Browse files
authored
STY: Add flake8-slots and flake8-raise rules (#58161)
* Use noqa instead of a pre-commit section * Add refurb rule * Add flake8-slots/raise
1 parent c85a210 commit 5c68fce

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

.pre-commit-config.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ repos:
3030
files: ^pandas
3131
exclude: ^pandas/tests
3232
args: [--select, "ANN001,ANN2", --fix-only, --exit-non-zero-on-fix]
33-
- id: ruff
34-
name: ruff-use-pd_array-in-core
35-
alias: ruff-use-pd_array-in-core
36-
files: ^pandas/core/
37-
exclude: ^pandas/core/api\.py$
38-
args: [--select, "ICN001", --exit-non-zero-on-fix]
3933
- id: ruff-format
4034
exclude: ^scripts
4135
- repo: https://github.com/jendrikseipp/vulture

pandas/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
UInt64Dtype,
4242
)
4343
from pandas.core.arrays.string_ import StringDtype
44-
from pandas.core.construction import array
44+
from pandas.core.construction import array # noqa: ICN001
4545
from pandas.core.flags import Flags
4646
from pandas.core.groupby import (
4747
Grouper,

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6729,7 +6729,7 @@ def _pad_or_backfill(
67296729

67306730
if axis == 1:
67316731
if not self._mgr.is_single_block and inplace:
6732-
raise NotImplementedError()
6732+
raise NotImplementedError
67336733
# e.g. test_align_fill_method
67346734
result = self.T._pad_or_backfill(
67356735
method=method, limit=limit, limit_area=limit_area

pandas/core/indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1191,13 +1191,13 @@ def __getitem__(self, key):
11911191
return self._getitem_axis(maybe_callable, axis=axis)
11921192

11931193
def _is_scalar_access(self, key: tuple):
1194-
raise NotImplementedError()
1194+
raise NotImplementedError
11951195

11961196
def _getitem_tuple(self, tup: tuple):
11971197
raise AbstractMethodError(self)
11981198

11991199
def _getitem_axis(self, key, axis: AxisInt):
1200-
raise NotImplementedError()
1200+
raise NotImplementedError
12011201

12021202
def _has_valid_setitem_indexer(self, indexer) -> bool:
12031203
raise AbstractMethodError(self)

pandas/core/interchange/buffer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __dlpack__(self) -> Any:
114114
"""
115115
Represent this structure as DLPack interface.
116116
"""
117-
raise NotImplementedError()
117+
raise NotImplementedError
118118

119119
def __dlpack_device__(self) -> tuple[DlpackDeviceType, int | None]:
120120
"""

pandas/io/stata.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ def _get_time_stamp(self) -> str:
13761376
elif self._format_version > 104:
13771377
return self._decode(self._path_or_buf.read(18))
13781378
else:
1379-
raise ValueError()
1379+
raise ValueError
13801380

13811381
def _get_seek_variable_labels(self) -> int:
13821382
if self._format_version == 117:
@@ -1388,7 +1388,7 @@ def _get_seek_variable_labels(self) -> int:
13881388
elif self._format_version >= 118:
13891389
return self._read_int64() + 17
13901390
else:
1391-
raise ValueError()
1391+
raise ValueError
13921392

13931393
def _read_old_header(self, first_char: bytes) -> None:
13941394
self._format_version = int(first_char[0])

pandas/tests/config/test_localization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_can_set_locale_invalid_get(monkeypatch):
9292
# but a subsequent getlocale() raises a ValueError.
9393

9494
def mock_get_locale():
95-
raise ValueError()
95+
raise ValueError
9696

9797
with monkeypatch.context() as m:
9898
m.setattr(locale, "getlocale", mock_get_locale)

pandas/tests/frame/indexing/test_setitem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TestDataFrameSetItem:
4141
def test_setitem_str_subclass(self):
4242
# GH#37366
4343
class mystring(str):
44-
pass
44+
__slots__ = ()
4545

4646
data = ["2020-10-22 01:21:00+00:00"]
4747
index = DatetimeIndex(data)

pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ select = [
234234
"G",
235235
# flake8-future-annotations
236236
"FA",
237+
# unconventional-import-alias
238+
"ICN001",
239+
# flake8-slots
240+
"SLOT",
241+
# flake8-raise
242+
"RSE"
237243
]
238244

239245
ignore = [

0 commit comments

Comments
 (0)