1- from collections import Counter
1+ import collections
22from datetime import datetime
33from functools import wraps
44import operator
55import os
66import re
77import string
8- from typing import Callable , ContextManager , List , Type
8+ from typing import Callable , ContextManager , Counter , List , Type
99import warnings
1010
1111import numpy as np
@@ -568,7 +568,7 @@ def makeCustomIndex(
568568
569569 assert all (x > 0 for x in ndupe_l )
570570
571- tuples = []
571+ list_of_lists = []
572572 for i in range (nlevels ):
573573
574574 def keyfunc (x ):
@@ -579,16 +579,18 @@ def keyfunc(x):
579579
580580 # build a list of lists to create the index from
581581 div_factor = nentries // ndupe_l [i ] + 1
582- # pandas\_testing.py:2148: error: Need type annotation for 'cnt'
583- cnt = Counter () # type: ignore[var-annotated]
582+
583+ # Deprecated since version 3.9: collections.Counter now supports []. See PEP 585
584+ # and Generic Alias Type.
585+ cnt : Counter [str ] = collections .Counter ()
584586 for j in range (div_factor ):
585587 label = f"{ prefix } _l{ i } _g{ j } "
586588 cnt [label ] = ndupe_l [i ]
587589 # cute Counter trick
588590 result = sorted (cnt .elements (), key = keyfunc )[:nentries ]
589- tuples .append (result )
591+ list_of_lists .append (result )
590592
591- tuples = list (zip (* tuples ))
593+ tuples = list (zip (* list_of_lists ))
592594
593595 # convert tuples to index
594596 if nentries == 1 :
0 commit comments