From b5305346e84e85f8777b925ff2959668b636cb9a Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 28 Jun 2019 11:09:01 -0500 Subject: [PATCH 1/2] Enabled stricter type checking --- mypy.ini | 1 + pandas/core/arrays/period.py | 2 +- pandas/core/nanops.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mypy.ini b/mypy.ini index d29beeca73f1b..cba20d2775fbe 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,6 @@ [mypy] ignore_missing_imports=True +no_implicit_optional=True [mypy-pandas.conftest,pandas.tests.*] ignore_errors=True \ No newline at end of file diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 3a9322773fc69..bb144764a26fc 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -195,7 +195,7 @@ def _simple_new(cls, values, freq=None, **kwargs): def _from_sequence( cls, scalars: Sequence[Optional[Period]], - dtype: PeriodDtype = None, + dtype: Optional[PeriodDtype] = None, copy: bool = False, ) -> ABCPeriodArray: if dtype: diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 24a28bf0005cb..834a3bc3d8bbb 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -228,7 +228,8 @@ def _maybe_get_mask(values: np.ndarray, skipna: bool, def _get_values(values: np.ndarray, skipna: bool, fill_value: Any = None, - fill_value_typ: str = None, mask: Optional[np.ndarray] = None + fill_value_typ: Optional[str] = None, + mask: Optional[np.ndarray] = None ) -> Tuple[np.ndarray, Optional[np.ndarray], np.dtype, np.dtype, Any]: """ Utility to get the values view, mask, dtype, dtype_max, and fill_value. From 6e9da10456111bca3eb0b807c65ac146b15f8e67 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 28 Jun 2019 12:33:55 -0500 Subject: [PATCH 2/2] CI fixes --- pandas/core/dtypes/dtypes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 9da6fb84ee18b..81e061a0fc7b4 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -214,13 +214,13 @@ class CategoricalDtype(PandasExtensionDtype, ExtensionDtype): _metadata = ('categories', 'ordered') _cache = {} # type: Dict[str_type, PandasExtensionDtype] - def __init__(self, categories=None, ordered: bool = None): + def __init__(self, categories=None, ordered: Optional[bool] = None): self._finalize(categories, ordered, fastpath=False) @classmethod def _from_fastpath(cls, categories=None, - ordered: bool = None + ordered: Optional[bool] = None ) -> 'CategoricalDtype': self = cls.__new__(cls) self._finalize(categories, ordered, fastpath=True) @@ -230,7 +230,7 @@ def _from_fastpath(cls, def _from_categorical_dtype(cls, dtype: 'CategoricalDtype', categories=None, - ordered: bool = None, + ordered: Optional[bool] = None, ) -> 'CategoricalDtype': if categories is ordered is None: return dtype @@ -244,8 +244,8 @@ def _from_categorical_dtype(cls, def _from_values_or_dtype(cls, values=None, categories=None, - ordered: bool = None, - dtype: 'CategoricalDtype' = None, + ordered: Optional[bool] = None, + dtype: Optional['CategoricalDtype'] = None, ) -> 'CategoricalDtype': """ Construct dtype from the input parameters used in :class:`Categorical`.