From 0c0634418fe80644cd60a7eb685582fc819b401f Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sat, 26 Mar 2022 15:17:50 +0100 Subject: [PATCH] TYP: Fix core/groupby/generic.py lexsort attr-defined type ignore GH37715 --- pandas/core/groupby/generic.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 245e33fb1a23b..f725ae061cedb 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -26,7 +26,10 @@ import numpy as np -from pandas._libs import reduction as libreduction +from pandas._libs import ( + Interval, + reduction as libreduction, +) from pandas._typing import ( ArrayLike, Manager, @@ -652,12 +655,9 @@ def value_counts( if is_interval_dtype(lab.dtype): # TODO: should we do this inside II? + lab_interval = cast(Interval, lab) - # error: "ndarray" has no attribute "left" - # error: "ndarray" has no attribute "right" - sorter = np.lexsort( - (lab.left, lab.right, ids) # type: ignore[attr-defined] - ) + sorter = np.lexsort((lab_interval.left, lab_interval.right, ids)) else: sorter = np.lexsort((lab, ids))