Skip to content

Commit 8aba25d

Browse files
simonjayhawkinsTomAugspurger
authored andcommitted
pandas\core\groupby\grouper.py:422: error: Implicit generic "Any". Use "typing.Dict" and specify generic parameters
1 parent c6ba046 commit 8aba25d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pandas/core/arrays/categorical.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import operator
22
from shutil import get_terminal_size
3-
from typing import List, Type, Union, cast
3+
from typing import Dict, Hashable, List, Type, Union, cast
44
from warnings import warn
55

66
import numpy as np
@@ -2067,7 +2067,7 @@ def __setitem__(self, key, value):
20672067
lindexer = self._maybe_coerce_indexer(lindexer)
20682068
self._codes[key] = lindexer
20692069

2070-
def _reverse_indexer(self):
2070+
def _reverse_indexer(self) -> Dict[Hashable, np.ndarray]:
20712071
"""
20722072
Compute the inverse of a categorical, returning
20732073
a dict of categories -> indexers.
@@ -2097,8 +2097,8 @@ def _reverse_indexer(self):
20972097
self.codes.astype("int64"), categories.size
20982098
)
20992099
counts = counts.cumsum()
2100-
result = (r[start:end] for start, end in zip(counts, counts[1:]))
2101-
result = dict(zip(categories, result))
2100+
_result = (r[start:end] for start, end in zip(counts, counts[1:]))
2101+
result = dict(zip(categories, _result))
21022102
return result
21032103

21042104
# reduction ops #

pandas/core/groupby/grouper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
split-apply-combine paradigm.
44
"""
55

6-
from typing import Hashable, List, Optional, Tuple
6+
from typing import Dict, Hashable, List, Optional, Tuple
77

88
import numpy as np
99

@@ -419,7 +419,7 @@ def _make_codes(self) -> None:
419419
self._group_index = uniques
420420

421421
@cache_readonly
422-
def groups(self) -> dict:
422+
def groups(self) -> Dict[Hashable, np.ndarray]:
423423
return self.index.groupby(Categorical.from_codes(self.codes, self.group_index))
424424

425425

pandas/core/indexes/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime
22
import operator
33
from textwrap import dedent
4-
from typing import FrozenSet, Hashable, Optional, Union
4+
from typing import Dict, FrozenSet, Hashable, Optional, Union
55
import warnings
66

77
import numpy as np
@@ -4594,7 +4594,7 @@ def _maybe_promote(self, other):
45944594
return self.astype("object"), other.astype("object")
45954595
return self, other
45964596

4597-
def groupby(self, values):
4597+
def groupby(self, values) -> Dict[Hashable, np.ndarray]:
45984598
"""
45994599
Group the index labels by a given array of values.
46004600
@@ -4605,7 +4605,7 @@ def groupby(self, values):
46054605
46064606
Returns
46074607
-------
4608-
groups : dict
4608+
dict
46094609
{group name -> group labels}
46104610
"""
46114611

0 commit comments

Comments
 (0)