Skip to content

Commit cc1b7ed

Browse files
TYP: remove ignore from makeCustomIndex (#39057)
1 parent 8fe3dc6 commit cc1b7ed

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pandas/_testing/__init__.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from collections import Counter
1+
import collections
22
from datetime import datetime
33
from functools import wraps
44
import operator
55
import os
66
import re
77
import string
8-
from typing import Callable, ContextManager, List, Type
8+
from typing import Callable, ContextManager, Counter, List, Type
99
import warnings
1010

1111
import 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

Comments
 (0)