From dbcee29d7471707ff23c9a1df43e3532126fca49 Mon Sep 17 00:00:00 2001 From: Gregory Rome Date: Tue, 30 Apr 2019 18:48:36 -0500 Subject: [PATCH 1/2] Fix type annotation in pandas.compat --- mypy.ini | 3 --- pandas/compat/__init__.py | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/mypy.ini b/mypy.ini index 596d71c77317e..63ccb6eb994ba 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,9 +5,6 @@ follow_imports=silent [mypy-pandas.conftest,pandas.tests.*] ignore_errors=True -[mypy-pandas.compat] -ignore_errors=True - [mypy-pandas.core.api] ignore_errors=True diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index 5c256a53b5036..51e5741485977 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -74,11 +74,9 @@ def raise_with_traceback(exc, traceback=Ellipsis): raise exc.with_traceback(traceback) -# In Python 3.7, the private re._pattern_type is removed. -# Python 3.5+ have typing.re.Pattern if PY36: - import typing - re_type = typing.re.Pattern + from typing import Pattern, Type + re_type = Pattern # type: Type[Pattern] else: re_type = type(re.compile('')) From f1ec34c32ced3885dff923cfb36207b3661b949b Mon Sep 17 00:00:00 2001 From: Gregory Rome Date: Wed, 1 May 2019 16:07:22 -0500 Subject: [PATCH 2/2] Remove PY36 condition for regex type --- pandas/compat/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index 51e5741485977..32b3d318dd57c 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -11,9 +11,9 @@ * platform checker """ import platform -import re import struct import sys +from typing import Pattern PY36 = sys.version_info >= (3, 6) PY37 = sys.version_info >= (3, 7) @@ -74,11 +74,7 @@ def raise_with_traceback(exc, traceback=Ellipsis): raise exc.with_traceback(traceback) -if PY36: - from typing import Pattern, Type - re_type = Pattern # type: Type[Pattern] -else: - re_type = type(re.compile('')) +re_type = Pattern # https://github.com/pandas-dev/pandas/pull/9123