Skip to content

STY: Add flake8-slots and flake8-raise rules #58161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ repos:
files: ^pandas
exclude: ^pandas/tests
args: [--select, "ANN001,ANN2", --fix-only, --exit-non-zero-on-fix]
- id: ruff
name: ruff-use-pd_array-in-core
alias: ruff-use-pd_array-in-core
files: ^pandas/core/
exclude: ^pandas/core/api\.py$
args: [--select, "ICN001", --exit-non-zero-on-fix]
- id: ruff-format
exclude: ^scripts
- repo: https://github.com/jendrikseipp/vulture
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
UInt64Dtype,
)
from pandas.core.arrays.string_ import StringDtype
from pandas.core.construction import array
from pandas.core.construction import array # noqa: ICN001
from pandas.core.flags import Flags
from pandas.core.groupby import (
Grouper,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6729,7 +6729,7 @@ def _pad_or_backfill(

if axis == 1:
if not self._mgr.is_single_block and inplace:
raise NotImplementedError()
raise NotImplementedError
# e.g. test_align_fill_method
result = self.T._pad_or_backfill(
method=method, limit=limit, limit_area=limit_area
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,13 +1191,13 @@ def __getitem__(self, key):
return self._getitem_axis(maybe_callable, axis=axis)

def _is_scalar_access(self, key: tuple):
raise NotImplementedError()
raise NotImplementedError

def _getitem_tuple(self, tup: tuple):
raise AbstractMethodError(self)

def _getitem_axis(self, key, axis: AxisInt):
raise NotImplementedError()
raise NotImplementedError

def _has_valid_setitem_indexer(self, indexer) -> bool:
raise AbstractMethodError(self)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/interchange/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __dlpack__(self) -> Any:
"""
Represent this structure as DLPack interface.
"""
raise NotImplementedError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to see this become consistent

raise NotImplementedError

def __dlpack_device__(self) -> tuple[DlpackDeviceType, int | None]:
"""
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ def _get_time_stamp(self) -> str:
elif self._format_version > 104:
return self._decode(self._path_or_buf.read(18))
else:
raise ValueError()
raise ValueError

def _get_seek_variable_labels(self) -> int:
if self._format_version == 117:
Expand All @@ -1388,7 +1388,7 @@ def _get_seek_variable_labels(self) -> int:
elif self._format_version >= 118:
return self._read_int64() + 17
else:
raise ValueError()
raise ValueError

def _read_old_header(self, first_char: bytes) -> None:
self._format_version = int(first_char[0])
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/config/test_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_can_set_locale_invalid_get(monkeypatch):
# but a subsequent getlocale() raises a ValueError.

def mock_get_locale():
raise ValueError()
raise ValueError

with monkeypatch.context() as m:
m.setattr(locale, "getlocale", mock_get_locale)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TestDataFrameSetItem:
def test_setitem_str_subclass(self):
# GH#37366
class mystring(str):
pass
__slots__ = ()

data = ["2020-10-22 01:21:00+00:00"]
index = DatetimeIndex(data)
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ select = [
"G",
# flake8-future-annotations
"FA",
# unconventional-import-alias
"ICN001",
# flake8-slots
"SLOT",
# flake8-raise
"RSE"
]

ignore = [
Expand Down