Skip to content
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
2 changes: 1 addition & 1 deletion pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
# scalars

PythonScalar = Union[str, int, float, bool]
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta")
DatetimeLikeScalar = Union["Period", "Timestamp", "Timedelta"]
PandasScalar = Union["Period", "Timestamp", "Timedelta", "Interval"]
Scalar = Union[PythonScalar, PandasScalar]

Expand Down
12 changes: 4 additions & 8 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,7 @@ def _validate_comparison_value(self, other):
raise InvalidComparison(other)

if isinstance(other, self._recognized_scalars) or other is NaT:
# error: Too many arguments for "object"
other = self._scalar_type(other) # type: ignore[call-arg]
other = self._scalar_type(other)
try:
self._check_compatible_with(other)
except (TypeError, IncompatibleFrequency) as err:
Expand Down Expand Up @@ -614,16 +613,14 @@ def _validate_shift_value(self, fill_value):
if is_valid_na_for_dtype(fill_value, self.dtype):
fill_value = NaT
elif isinstance(fill_value, self._recognized_scalars):
# error: Too many arguments for "object"
fill_value = self._scalar_type(fill_value) # type: ignore[call-arg]
fill_value = self._scalar_type(fill_value)
else:
# only warn if we're not going to raise
if self._scalar_type is Period and lib.is_integer(fill_value):
# kludge for #31971 since Period(integer) tries to cast to str
new_fill = Period._from_ordinal(fill_value, freq=self.freq)
else:
# error: Too many arguments for "object"
new_fill = self._scalar_type(fill_value) # type: ignore[call-arg]
new_fill = self._scalar_type(fill_value)

# stacklevel here is chosen to be correct when called from
# DataFrame.shift or Series.shift
Expand Down Expand Up @@ -684,8 +681,7 @@ def _validate_scalar(
raise TypeError(msg)

elif isinstance(value, self._recognized_scalars):
# error: Too many arguments for "object"
value = self._scalar_type(value) # type: ignore[call-arg]
value = self._scalar_type(value)

else:
msg = self._validation_error_message(value, allow_listlike)
Expand Down