Skip to content

Commit 6ba2a67

Browse files
authored
TYP: annotate functions that always error with NoReturn (#48002)
1 parent 8cb64ab commit 6ba2a67

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pandas/core/groupby/ops.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Generic,
1616
Hashable,
1717
Iterator,
18+
NoReturn,
1819
Sequence,
1920
final,
2021
)
@@ -1243,7 +1244,7 @@ def groupings(self) -> list[grouper.Grouping]:
12431244
ping = grouper.Grouping(lev, lev, in_axis=False, level=None)
12441245
return [ping]
12451246

1246-
def _aggregate_series_fast(self, obj: Series, func: Callable) -> np.ndarray:
1247+
def _aggregate_series_fast(self, obj: Series, func: Callable) -> NoReturn:
12471248
# -> np.ndarray[object]
12481249
raise NotImplementedError(
12491250
"This should not be reached; use _aggregate_series_pure_python"

pandas/core/indexes/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Hashable,
1313
Iterable,
1414
Literal,
15+
NoReturn,
1516
Sequence,
1617
TypeVar,
1718
cast,
@@ -3166,7 +3167,7 @@ def __xor__(self, other):
31663167
return self.symmetric_difference(other)
31673168

31683169
@final
3169-
def __nonzero__(self):
3170+
def __nonzero__(self) -> NoReturn:
31703171
raise ValueError(
31713172
f"The truth value of a {type(self).__name__} is ambiguous. "
31723173
"Use a.empty, a.bool(), a.item(), a.any() or a.all()."

pandas/core/indexes/frozen.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"""
99
from __future__ import annotations
1010

11-
from typing import Any
11+
from typing import (
12+
Any,
13+
NoReturn,
14+
)
1215

1316
from pandas.core.base import PandasObject
1417

@@ -93,7 +96,7 @@ def __reduce__(self):
9396
def __hash__(self) -> int: # type: ignore[override]
9497
return hash(tuple(self))
9598

96-
def _disabled(self, *args, **kwargs):
99+
def _disabled(self, *args, **kwargs) -> NoReturn:
97100
"""
98101
This method will not function because object is immutable.
99102
"""

0 commit comments

Comments
 (0)