Skip to content

Commit edd49db

Browse files
committed
mypy fixup
1 parent 17f103c commit edd49db

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pandas/core/ops/__init__.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ def maybe_upcast_for_op(obj, shape: Tuple[int, ...]):
149149
Be careful to call this *after* determining the `name` attribute to be
150150
attached to the result of the arithmetic operation.
151151
"""
152+
from pandas.core.arrays import TimedeltaArray
153+
152154
if type(obj) is datetime.timedelta:
153155
# GH#22390 cast up to Timedelta to rely on Timedelta
154156
# implementation; otherwise operation against numeric-dtype
@@ -161,9 +163,6 @@ def maybe_upcast_for_op(obj, shape: Tuple[int, ...]):
161163
# we broadcast and wrap in a TimedeltaArray
162164
obj = obj.astype("timedelta64[ns]")
163165
right = np.broadcast_to(obj, shape)
164-
165-
from pandas.core.arrays import TimedeltaArray
166-
167166
return TimedeltaArray(right)
168167

169168
# In particular non-nanosecond timedelta64 needs to be cast to
@@ -175,8 +174,6 @@ def maybe_upcast_for_op(obj, shape: Tuple[int, ...]):
175174
# GH#22390 Unfortunately we need to special-case right-hand
176175
# timedelta64 dtypes because numpy casts integer dtypes to
177176
# timedelta64 when operating with timedelta64
178-
from pandas.core.arrays import TimedeltaArray
179-
180177
return TimedeltaArray._from_sequence(obj)
181178
return obj
182179

0 commit comments

Comments
 (0)