Skip to content

Commit ba0fba4

Browse files
committed
Add type-ignore
1 parent ffcff02 commit ba0fba4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/core/groupby/groupby.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,11 +1724,12 @@ def _agg_py_fallback(
17241724
# preserve the kind of exception that raised
17251725
raise type(err)(msg) from err
17261726

1727-
if ser.dtype == object:
1727+
dtype = ser.dtype
1728+
if dtype == object:
17281729
res_values = res_values.astype(object, copy=False)
1729-
elif is_string_dtype(ser.dtype) and how in ["min", "max"]:
1730-
dtype = ser.dtype
1731-
string_array_cls = dtype.construct_array_type()
1730+
elif is_string_dtype(dtype) and how in ["min", "max"]:
1731+
# mypy doesn't infer dtype is an ExtensionDtype
1732+
string_array_cls = dtype.construct_array_type() # type: ignore[union-attr]
17321733
res_values = string_array_cls._from_sequence(res_values, dtype=dtype)
17331734

17341735
# If we are DataFrameGroupBy and went through a SeriesGroupByPath

0 commit comments

Comments
 (0)