Skip to content

Commit 392c7b8

Browse files
simonjayhawkinsTomAugspurger
authored andcommitted
TYP: check_untyped_defs various (#30572)
1 parent 4b0f75d commit 392c7b8

File tree

7 files changed

+14
-21
lines changed

7 files changed

+14
-21
lines changed

pandas/compat/pickle_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ def __new__(cls) -> "DataFrame": # type: ignore
169169

170170

171171
# our Unpickler sub-class to override methods and some dispatcher
172-
# functions for compat
173-
172+
# functions for compat and uses a non-public class of the pickle module.
174173

174+
# error: Name 'pkl._Unpickler' is not defined
175175
class Unpickler(pkl._Unpickler): # type: ignore
176176
def find_class(self, module, name):
177177
# override superclass

pandas/core/arrays/sparse/dtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class SparseDtype(ExtensionDtype):
6464
# hash(nan) is (sometimes?) 0.
6565
_metadata = ("_dtype", "_fill_value", "_is_na_fill_value")
6666

67-
def __init__(self, dtype: Dtype = np.float64, fill_value: Any = None) -> None:
67+
def __init__(self, dtype: Dtype = np.float64, fill_value: Any = None):
6868

6969
if isinstance(dtype, type(self)):
7070
if fill_value is None:

pandas/core/config_init.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,15 @@ def table_schema_cb(key):
300300
_enable_data_resource_formatter(cf.get_option(key))
301301

302302

303-
def is_terminal():
303+
def is_terminal() -> bool:
304304
"""
305305
Detect if Python is running in a terminal.
306306
307307
Returns True if Python is running in a terminal or False if not.
308308
"""
309309
try:
310-
ip = get_ipython()
310+
# error: Name 'get_ipython' is not defined
311+
ip = get_ipython() # type: ignore
311312
except NameError: # assume standard Python interpreter in a terminal
312313
return True
313314
else:

pandas/core/dtypes/generic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
# define abstract base classes to enable isinstance type checking on our
55
# objects
66
def create_pandas_abc_type(name, attr, comp):
7-
@classmethod
7+
8+
# https://github.com/python/mypy/issues/1006
9+
# error: 'classmethod' used with a non-method
10+
@classmethod # type: ignore
811
def _check(cls, inst) -> bool:
912
return getattr(inst, attr, "_typ") in comp
1013

pandas/core/groupby/groupby.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,9 +2540,9 @@ def get_groupby(
25402540
squeeze: bool = False,
25412541
observed: bool = False,
25422542
mutated: bool = False,
2543-
):
2543+
) -> GroupBy:
25442544

2545-
klass: Union[Type["SeriesGroupBy"], Type["DataFrameGroupBy"]]
2545+
klass: Type[GroupBy]
25462546
if isinstance(obj, Series):
25472547
from pandas.core.groupby.generic import SeriesGroupBy
25482548

pandas/core/indexes/category.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import operator
2-
from typing import Any
2+
from typing import Any, List
33

44
import numpy as np
55

@@ -583,6 +583,7 @@ def reindex(self, target, method=None, level=None, limit=None, tolerance=None):
583583

584584
target = ibase.ensure_index(target)
585585

586+
missing: List[int]
586587
if self.equals(target):
587588
indexer = None
588589
missing = []

setup.cfg

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,9 @@ check_untyped_defs=False
181181
[mypy-pandas.core.computation.scope]
182182
check_untyped_defs=False
183183

184-
[mypy-pandas.core.config_init]
185-
check_untyped_defs=False
186-
187184
[mypy-pandas.core.dtypes.cast]
188185
check_untyped_defs=False
189186

190-
[mypy-pandas.core.dtypes.generic]
191-
check_untyped_defs=False
192-
193187
[mypy-pandas.core.frame]
194188
check_untyped_defs=False
195189

@@ -208,9 +202,6 @@ check_untyped_defs=False
208202
[mypy-pandas.core.indexes.base]
209203
check_untyped_defs=False
210204

211-
[mypy-pandas.core.indexes.category]
212-
check_untyped_defs=False
213-
214205
[mypy-pandas.core.indexes.datetimelike]
215206
check_untyped_defs=False
216207

@@ -256,9 +247,6 @@ check_untyped_defs=False
256247
[mypy-pandas.core.reshape.reshape]
257248
check_untyped_defs=False
258249

259-
[mypy-pandas.core.series]
260-
check_untyped_defs=False
261-
262250
[mypy-pandas.core.strings]
263251
check_untyped_defs=False
264252

0 commit comments

Comments
 (0)