Skip to content

TYP: check_untyped_defs various #30572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ def __new__(cls) -> "DataFrame": # type: ignore


# our Unpickler sub-class to override methods and some dispatcher
# functions for compat

# functions for compat and uses a non-public class of the pickle module.

# error: Name 'pkl._Unpickler' is not defined
class Unpickler(pkl._Unpickler): # type: ignore
def find_class(self, module, name):
# override superclass
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/sparse/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SparseDtype(ExtensionDtype):
# hash(nan) is (sometimes?) 0.
_metadata = ("_dtype", "_fill_value", "_is_na_fill_value")

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

if isinstance(dtype, type(self)):
if fill_value is None:
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,15 @@ def table_schema_cb(key):
_enable_data_resource_formatter(cf.get_option(key))


def is_terminal():
def is_terminal() -> bool:
"""
Detect if Python is running in a terminal.

Returns True if Python is running in a terminal or False if not.
"""
try:
ip = get_ipython()
# error: Name 'get_ipython' is not defined
ip = get_ipython() # type: ignore
except NameError: # assume standard Python interpreter in a terminal
return True
else:
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/dtypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
# define abstract base classes to enable isinstance type checking on our
# objects
def create_pandas_abc_type(name, attr, comp):
@classmethod

# https://github.com/python/mypy/issues/1006
# error: 'classmethod' used with a non-method
@classmethod # type: ignore
def _check(cls, inst) -> bool:
return getattr(inst, attr, "_typ") in comp

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2528,9 +2528,9 @@ def get_groupby(
squeeze: bool = False,
observed: bool = False,
mutated: bool = False,
):
) -> GroupBy:

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

Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import operator
from typing import Any
from typing import Any, List

import numpy as np

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

target = ibase.ensure_index(target)

missing: List[int]
if self.equals(target):
indexer = None
missing = []
Expand Down
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,9 @@ check_untyped_defs=False
[mypy-pandas.core.computation.scope]
check_untyped_defs=False

[mypy-pandas.core.config_init]
check_untyped_defs=False

[mypy-pandas.core.dtypes.cast]
check_untyped_defs=False

[mypy-pandas.core.dtypes.generic]
check_untyped_defs=False

[mypy-pandas.core.frame]
check_untyped_defs=False

Expand All @@ -208,9 +202,6 @@ check_untyped_defs=False
[mypy-pandas.core.indexes.base]
check_untyped_defs=False

[mypy-pandas.core.indexes.category]
check_untyped_defs=False

[mypy-pandas.core.indexes.datetimelike]
check_untyped_defs=False

Expand Down Expand Up @@ -256,9 +247,6 @@ check_untyped_defs=False
[mypy-pandas.core.reshape.reshape]
check_untyped_defs=False

[mypy-pandas.core.series]
check_untyped_defs=False

[mypy-pandas.core.strings]
check_untyped_defs=False

Expand Down