From a8b2d931695a8220f5d294ea2c0507494db9d68d Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 2 Nov 2019 11:48:38 +0000 Subject: [PATCH 1/6] Activate mypy and fix issues in test_offsets --- pandas/tests/tseries/offsets/test_offsets.py | 14 ++++++++------ setup.cfg | 3 --- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 81aff4211440e..1b575770739fc 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -1,5 +1,5 @@ from datetime import date, datetime, time as dt_time, timedelta -from typing import Type +from typing import Type, List, Tuple, Dict import numpy as np import pytest @@ -90,7 +90,7 @@ def test_to_M8(): ##### # DateOffset Tests ##### - +OffsetTestCaseList = List[Tuple[int, Dict[datetime, datetime]]] class Base: _offset = None # type: Type[DateOffset] @@ -662,6 +662,8 @@ def test_eq(self): class TestBusinessDay(Base): _offset = BDay + + def setup_method(self, method): self.d = datetime(2008, 1, 1) @@ -741,7 +743,7 @@ def test_onOffset(self): for offset, d, expected in tests: assert_onOffset(offset, d, expected) - apply_cases = [] + apply_cases = [] # type: OffsetTestCaseList apply_cases.append( ( BDay(), @@ -2629,7 +2631,7 @@ def test_onOffset(self, case): offset, d, expected = case assert_onOffset(offset, d, expected) - apply_cases = [] + apply_cases = [] # type: OffsetTestCaseList apply_cases.append( ( CDay(), @@ -2876,7 +2878,7 @@ def test_onOffset(self, case): offset, d, expected = case assert_onOffset(offset, d, expected) - apply_cases = [] + apply_cases = [] # type: OffsetTestCaseList apply_cases.append( ( CBMonthEnd(), @@ -3025,7 +3027,7 @@ def test_onOffset(self, case): offset, dt, expected = case assert_onOffset(offset, dt, expected) - apply_cases = [] + apply_cases = [] # type: OffsetTestCaseList apply_cases.append( ( CBMonthBegin(), diff --git a/setup.cfg b/setup.cfg index d4657100c1291..3207e598ff6ee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -159,6 +159,3 @@ ignore_errors=True [mypy-pandas.tests.series.test_operators] ignore_errors=True - -[mypy-pandas.tests.tseries.offsets.test_offsets] -ignore_errors=True From 4340a3ca8c3aa1bfd2224c4c489aab5b6882da06 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 2 Nov 2019 11:50:31 +0000 Subject: [PATCH 2/6] flake8 --- pandas/tests/tseries/offsets/test_offsets.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 1b575770739fc..be5ad720c1e7c 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -92,6 +92,7 @@ def test_to_M8(): ##### OffsetTestCaseList = List[Tuple[int, Dict[datetime, datetime]]] + class Base: _offset = None # type: Type[DateOffset] d = Timestamp(datetime(2008, 1, 2)) @@ -662,8 +663,6 @@ def test_eq(self): class TestBusinessDay(Base): _offset = BDay - - def setup_method(self, method): self.d = datetime(2008, 1, 1) @@ -743,7 +742,7 @@ def test_onOffset(self): for offset, d, expected in tests: assert_onOffset(offset, d, expected) - apply_cases = [] # type: OffsetTestCaseList + apply_cases = [] # type: OffsetTestCaseList apply_cases.append( ( BDay(), From c26cd0f587adc610ca41c015d9059d84065d66cc Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 2 Nov 2019 12:25:52 +0000 Subject: [PATCH 3/6] isort --- pandas/tests/tseries/offsets/test_offsets.py | 2 +- web/pandas_web.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index be5ad720c1e7c..ff1e3cf5800ee 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -1,5 +1,5 @@ from datetime import date, datetime, time as dt_time, timedelta -from typing import Type, List, Tuple, Dict +from typing import Dict, List, Tuple, Type import numpy as np import pytest diff --git a/web/pandas_web.py b/web/pandas_web.py index d515d8a0e1cd7..d905d5be181a6 100644 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -34,8 +34,8 @@ import typing import feedparser -import markdown import jinja2 +import markdown import requests import yaml From ba1999820f1ad5161f45eaa7e13f875f7f7310a1 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 2 Nov 2019 14:09:11 +0000 Subject: [PATCH 4/6] don't change import order in pandas_web --- web/pandas_web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pandas_web.py b/web/pandas_web.py index d905d5be181a6..d515d8a0e1cd7 100644 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -34,8 +34,8 @@ import typing import feedparser -import jinja2 import markdown +import jinja2 import requests import yaml From 987b3f596e5731d69bd83d42675c49cb22f7ae4b Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 2 Nov 2019 14:10:36 +0000 Subject: [PATCH 5/6] Rename apply case type --- pandas/tests/tseries/offsets/test_offsets.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index ff1e3cf5800ee..226007c578d4e 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -90,7 +90,7 @@ def test_to_M8(): ##### # DateOffset Tests ##### -OffsetTestCaseList = List[Tuple[int, Dict[datetime, datetime]]] +_ApplyCases = List[Tuple[int, Dict[datetime, datetime]]] class Base: @@ -742,7 +742,7 @@ def test_onOffset(self): for offset, d, expected in tests: assert_onOffset(offset, d, expected) - apply_cases = [] # type: OffsetTestCaseList + apply_cases = [] # type: _ApplyCases apply_cases.append( ( BDay(), @@ -2630,7 +2630,7 @@ def test_onOffset(self, case): offset, d, expected = case assert_onOffset(offset, d, expected) - apply_cases = [] # type: OffsetTestCaseList + apply_cases = [] # type: _ApplyCases apply_cases.append( ( CDay(), @@ -2877,7 +2877,7 @@ def test_onOffset(self, case): offset, d, expected = case assert_onOffset(offset, d, expected) - apply_cases = [] # type: OffsetTestCaseList + apply_cases = [] # type: _ApplyCases apply_cases.append( ( CBMonthEnd(), @@ -3026,7 +3026,7 @@ def test_onOffset(self, case): offset, dt, expected = case assert_onOffset(offset, dt, expected) - apply_cases = [] # type: OffsetTestCaseList + apply_cases = [] # type: _ApplyCases apply_cases.append( ( CBMonthBegin(), From 6b27d7145194179f15a09fb032157719c0c82e53 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 6 Nov 2019 23:20:54 +0000 Subject: [PATCH 6/6] Use proper offset type not int in test offset cases --- pandas/tests/tseries/offsets/test_offsets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 226007c578d4e..bed8d2461f65d 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -31,6 +31,7 @@ import pandas.tseries.offsets as offsets from pandas.tseries.offsets import ( FY5253, + BaseOffset, BDay, BMonthBegin, BMonthEnd, @@ -90,7 +91,7 @@ def test_to_M8(): ##### # DateOffset Tests ##### -_ApplyCases = List[Tuple[int, Dict[datetime, datetime]]] +_ApplyCases = List[Tuple[BaseOffset, Dict[datetime, datetime]]] class Base: