Skip to content

Commit 367acde

Browse files
authored
fix: raise NotImplementedError instead of returning it (#2710)
1 parent 5168fe0 commit 367acde

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

narwhals/_arrow/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,11 @@ def extract_native(
237237
If one of the two sides has a `_broadcast` flag, then extract the scalar
238238
underneath it so that PyArrow can do its own broadcasting.
239239
"""
240-
from narwhals._arrow.dataframe import ArrowDataFrame
241240
from narwhals._arrow.series import ArrowSeries
242241

243242
if rhs is None: # pragma: no cover
244243
return lhs.native, lit(None, type=lhs._type)
245244

246-
if isinstance(rhs, ArrowDataFrame):
247-
return NotImplemented
248-
249245
if isinstance(rhs, ArrowSeries):
250246
if lhs._broadcast and not rhs._broadcast:
251247
return lhs.native[0], rhs.native

narwhals/_dask/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ def narwhals_to_native_dtype(dtype: IntoDType, version: Version) -> Any: # noqa
144144
return "timedelta64[ns]"
145145
if isinstance_or_issubclass(dtype, dtypes.List): # pragma: no cover
146146
msg = "Converting to List dtype is not supported yet"
147-
return NotImplementedError(msg)
147+
raise NotImplementedError(msg)
148148
if isinstance_or_issubclass(dtype, dtypes.Struct): # pragma: no cover
149149
msg = "Converting to Struct dtype is not supported yet"
150-
return NotImplementedError(msg)
150+
raise NotImplementedError(msg)
151151
if isinstance_or_issubclass(dtype, dtypes.Array): # pragma: no cover
152152
msg = "Converting to Array dtype is not supported yet"
153-
return NotImplementedError(msg)
153+
raise NotImplementedError(msg)
154154
if isinstance_or_issubclass(dtype, dtypes.Time): # pragma: no cover
155155
msg = "Converting to Time dtype is not supported yet"
156-
return NotImplementedError(msg)
156+
raise NotImplementedError(msg)
157157
if isinstance_or_issubclass(dtype, dtypes.Binary): # pragma: no cover
158158
msg = "Converting to Binary dtype is not supported yet"
159-
return NotImplementedError(msg)
159+
raise NotImplementedError(msg)
160160

161161
msg = f"Unknown dtype: {dtype}" # pragma: no cover
162162
raise AssertionError(msg)

narwhals/_pandas_like/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,10 @@ def align_and_extract_native(
9393
If the comparison isn't supported, return `NotImplemented` so that the
9494
"right-hand-side" operation (e.g. `__radd__`) can be tried.
9595
"""
96-
from narwhals._pandas_like.dataframe import PandasLikeDataFrame
9796
from narwhals._pandas_like.series import PandasLikeSeries
9897

9998
lhs_index = lhs.native.index
10099

101-
if isinstance(rhs, PandasLikeDataFrame):
102-
return NotImplemented
103-
104100
if lhs._broadcast and isinstance(rhs, PandasLikeSeries) and not rhs._broadcast:
105101
return lhs.native.iloc[0], rhs.native
106102

narwhals/_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,8 @@ def __get__(
17701770
# NOTE: Prefer not exposing the actual class we're defining in
17711771
# `_implementation` may not be available everywhere
17721772
who = getattr(instance, "_implementation", self._name_owner)
1773-
raise _not_implemented_error(self._name, who)
1773+
_raise_not_implemented_error(self._name, who)
1774+
return None # pragma: no cover
17741775

17751776
def __call__(self, *args: Any, **kwds: Any) -> Any:
17761777
# NOTE: Purely to duck-type as assignable to **any** instance method
@@ -1793,13 +1794,13 @@ def deprecated(cls, message: LiteralString, /) -> Self:
17931794
return deprecated(message)(obj)
17941795

17951796

1796-
def _not_implemented_error(what: str, who: str, /) -> NotImplementedError:
1797+
def _raise_not_implemented_error(what: str, who: str, /) -> NotImplementedError:
17971798
msg = (
17981799
f"{what!r} is not implemented for: {who!r}.\n\n"
17991800
"If you would like to see this functionality in `narwhals`, "
18001801
"please open an issue at: https://github.com/narwhals-dev/narwhals/issues"
18011802
)
1802-
return NotImplementedError(msg)
1803+
raise NotImplementedError(msg)
18031804

18041805

18051806
class requires: # noqa: N801

0 commit comments

Comments
 (0)