From c41979175eebd5a731b6bebd15648dd0c558d639 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Mon, 1 Apr 2019 23:21:15 +0530 Subject: [PATCH 1/4] remove the module from mypy.ini --- mypy.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index 49fce2e4047f7..b06dacd198f77 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,9 +5,6 @@ follow_imports=silent [mypy-pandas.conftest,pandas.tests.*] ignore_errors=True -[mypy-pandas._version] -ignore_errors=True - [mypy-pandas.compat] ignore_errors=True From 5872b7ed58d590bdecc9c26828cb076e3e2dd31d Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Mon, 1 Apr 2019 23:55:28 +0530 Subject: [PATCH 2/4] type variables of _version.py as indicated by mypy --- pandas/_version.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/_version.py b/pandas/_version.py index d000539421b91..5c0e2a82a6eff 100644 --- a/pandas/_version.py +++ b/pandas/_version.py @@ -12,6 +12,7 @@ import re import subprocess import sys +from typing import Dict from pandas.compat import PY3 @@ -48,8 +49,8 @@ class NotThisMethod(Exception): pass -LONG_VERSION_PY = {} -HANDLERS = {} +LONG_VERSION_PY = {} # type: Dict +HANDLERS = {} # type: Dict[str, Dict] def register_vcs_handler(vcs, method): # decorator From 802873e392e1b654eb8adfb8e6dda74ebfc5197c Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Tue, 2 Apr 2019 00:51:16 +0530 Subject: [PATCH 3/4] remove possible dead code, properly type HANDLERS and type the method register_vcs_handler L52: LONG_VERSION_PY looks like dead. --- pandas/_version.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_version.py b/pandas/_version.py index 5c0e2a82a6eff..92637d7a54405 100644 --- a/pandas/_version.py +++ b/pandas/_version.py @@ -12,7 +12,7 @@ import re import subprocess import sys -from typing import Dict +from typing import Callable, Dict from pandas.compat import PY3 @@ -49,11 +49,11 @@ class NotThisMethod(Exception): pass -LONG_VERSION_PY = {} # type: Dict -HANDLERS = {} # type: Dict[str, Dict] +# LONG_VERSION_PY = {} # type: Dict +HANDLERS = {} # type: Dict[str, Dict[str, Callable]] -def register_vcs_handler(vcs, method): # decorator +def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator def decorate(f): if vcs not in HANDLERS: HANDLERS[vcs] = {} From 3ed8317251e1137f8fc7fe47583e9a91209922c6 Mon Sep 17 00:00:00 2001 From: Vaibhav Vishal Date: Tue, 2 Apr 2019 15:02:39 +0530 Subject: [PATCH 4/4] remove dead code and type the decorator in a minimal way --- pandas/_version.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/_version.py b/pandas/_version.py index 92637d7a54405..2e46beff13e35 100644 --- a/pandas/_version.py +++ b/pandas/_version.py @@ -49,12 +49,11 @@ class NotThisMethod(Exception): pass -# LONG_VERSION_PY = {} # type: Dict HANDLERS = {} # type: Dict[str, Dict[str, Callable]] def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator - def decorate(f): + def decorate(f: Callable) -> Callable: if vcs not in HANDLERS: HANDLERS[vcs] = {} HANDLERS[vcs][method] = f