Skip to content

Commit d4bb4a4

Browse files
committed
refactor(ruff): ANN202
1 parent 0f71d07 commit d4bb4a4

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ ignore = [
199199
"PYI001", # https://docs.astral.sh/ruff/rules/unprefixed-type-param/
200200
"PYI042", # https://docs.astral.sh/ruff/rules/snake-case-type-alias/
201201
"TD003", # https://docs.astral.sh/ruff/rules/missing-todo-link/
202-
"ERA001", "ANN001", "ANN201", "ANN202", "ANN204", "ANN206", "ANN401", "PLR0402", "PLC0105"
202+
"ERA001", "ANN001", "ANN201", "ANN204", "ANN206", "ANN401", "PLR0402", "PLC0105"
203203
]
204204
"scripts/*" = [
205205
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
@@ -219,7 +219,7 @@ ignore = [
219219
"A001", # https://docs.astral.sh/ruff/rules/builtin-variable-shadowing/
220220
"PYI042", # https://docs.astral.sh/ruff/rules/snake-case-type-alias/
221221
"SLF001", # https://docs.astral.sh/ruff/rules/private-member-access/
222-
"ANN001", "ANN201", "ANN202", "ANN204", "ANN206", "ANN401", "ARG", "ERA", "RUF", "SIM", "TRY", "PT", "NPY", "N", "DTZ", "PLR", "TC", "PGH", "PTH", "S311", "C901"
222+
"ANN001", "ANN201", "ANN204", "ANN206", "ANN401", "ARG", "ERA", "RUF", "SIM", "TRY", "PT", "NPY", "N", "DTZ", "PLR", "TC", "PGH", "PTH", "S311", "C901"
223223
]
224224
"tests/test_io.py" = [
225225
# The following rules are ignored permanently for good reasons

tests/extension/decimal/array.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from builtins import type as type_t
4+
from collections.abc import Callable
45
import decimal
56
import numbers
67
import sys
@@ -23,7 +24,10 @@
2324
)
2425
from pandas.core.indexers import check_array_indexer
2526

26-
from pandas._typing import TakeIndexer
27+
from pandas._typing import (
28+
TakeIndexer,
29+
np_1darray,
30+
)
2731

2832
from pandas.core.dtypes.base import ExtensionDtype
2933
from pandas.core.dtypes.common import (
@@ -149,7 +153,7 @@ def __array_ufunc__(
149153
if result is not NotImplemented:
150154
return result
151155

152-
def reconstruct(x):
156+
def reconstruct(x) -> decimal.Decimal | numbers.Number | DecimalArray:
153157
if isinstance(x, (decimal.Decimal, numbers.Number)):
154158
return x
155159
return DecimalArray._from_sequence(x)
@@ -222,10 +226,10 @@ def isna(self):
222226
return np.array([x.is_nan() for x in self._data], dtype=bool)
223227

224228
@property
225-
def _na_value(self):
229+
def _na_value(self) -> decimal.Decimal:
226230
return decimal.Decimal("NaN")
227231

228-
def _formatter(self, boxed=False):
232+
def _formatter(self, boxed=False) -> Callable[..., str]:
229233
if boxed:
230234
return "Decimal: {}".format
231235
return repr
@@ -234,7 +238,7 @@ def _formatter(self, boxed=False):
234238
def _concat_same_type(cls, to_concat):
235239
return cls(np.concatenate([x._data for x in to_concat]))
236240

237-
def _reduce(self, name: str, *, skipna: bool = True, **kwargs: Any):
241+
def _reduce(self, name: str, *, skipna: bool = True, **kwargs: Any) -> Any:
238242
if skipna:
239243
# If we don't have any NAs, we can ignore skipna
240244
if self.isna().any():
@@ -253,9 +257,9 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs: Any):
253257
) from err
254258
return op(axis=0)
255259

256-
def _cmp_method(self, other, op):
260+
def _cmp_method(self, other, op) -> np_1darray[np.bool_]:
257261
# For use with OpsMixin
258-
def convert_values(param):
262+
def convert_values(param) -> ExtensionArray | list[Any]:
259263
if isinstance(param, ExtensionArray) or is_list_like(param):
260264
ovalues = param
261265
else:

0 commit comments

Comments
 (0)