From 904e07f648df29674f01d64078eae556a90bc27e Mon Sep 17 00:00:00 2001 From: galunid Date: Mon, 14 Oct 2019 11:49:32 +0200 Subject: [PATCH 1/4] Fix mypy error messages in pandas/test/tseries/offsets/test_offsets.py Fix import order --- pandas/tests/tseries/offsets/test_offsets.py | 25 ++++++++++---------- setup.cfg | 3 --- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index ddf2c6e65b474..f132b0eaee788 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -1,4 +1,5 @@ from datetime import date, datetime, time as dt_time, timedelta +from typing import Callable, Dict, List, Tuple, Union import numpy as np import pytest @@ -92,7 +93,7 @@ def test_to_M8(): class Base: - _offset = None + _offset = None # type: Union[BusinessHour, CustomBusinessHour, Callable] d = Timestamp(datetime(2008, 1, 2)) timezones = [ @@ -659,7 +660,7 @@ def test_eq(self): class TestBusinessDay(Base): - _offset = BDay + _offset = BDay # type: Callable def setup_method(self, method): self.d = datetime(2008, 1, 1) @@ -740,7 +741,7 @@ def test_onOffset(self): for offset, d, expected in tests: assert_onOffset(offset, d, expected) - apply_cases = [] + apply_cases = [] # type: List[Tuple[int, Dict[datetime, datetime]]] apply_cases.append( ( BDay(), @@ -1697,7 +1698,7 @@ def test_opening_time(self, case): assert offset._next_opening_time(dt) == exp_next assert offset._prev_opening_time(dt) == exp_prev - apply_cases = [] + apply_cases = [] # type: List[Tuple[int, Dict[datetime, datetime]]] apply_cases.append( ( BusinessHour(), @@ -2631,7 +2632,7 @@ def test_onOffset(self, case): apply_cases = [] apply_cases.append( ( - CDay(), + 1 * CDay(), { datetime(2008, 1, 1): datetime(2008, 1, 2), datetime(2008, 1, 4): datetime(2008, 1, 7), @@ -2878,7 +2879,7 @@ def test_onOffset(self, case): apply_cases = [] apply_cases.append( ( - CBMonthEnd(), + 1 * CBMonthEnd(), { datetime(2008, 1, 1): datetime(2008, 1, 31), datetime(2008, 2, 7): datetime(2008, 2, 29), @@ -3027,7 +3028,7 @@ def test_onOffset(self, case): apply_cases = [] apply_cases.append( ( - CBMonthBegin(), + 1 * CBMonthBegin(), { datetime(2008, 1, 1): datetime(2008, 2, 1), datetime(2008, 2, 7): datetime(2008, 3, 3), @@ -3120,7 +3121,7 @@ def test_datetimeindex(self): class TestWeek(Base): - _offset = Week + _offset = Week # type: Callable d = Timestamp(datetime(2008, 1, 2)) offset1 = _offset() offset2 = _offset(2) @@ -3219,7 +3220,7 @@ def test_onOffset(self, weekday): class TestWeekOfMonth(Base): - _offset = WeekOfMonth + _offset = WeekOfMonth # type: Callable offset1 = _offset() offset2 = _offset(2) @@ -3319,7 +3320,7 @@ def test_onOffset(self, case): class TestLastWeekOfMonth(Base): - _offset = LastWeekOfMonth + _offset = LastWeekOfMonth # type: Callable offset1 = _offset() offset2 = _offset(2) @@ -3396,7 +3397,7 @@ def test_onOffset(self, case): class TestSemiMonthEnd(Base): - _offset = SemiMonthEnd + _offset = SemiMonthEnd # type: Callable offset1 = _offset() offset2 = _offset(2) @@ -3655,7 +3656,7 @@ def test_vectorized_offset_addition(self, klass): class TestSemiMonthBegin(Base): - _offset = SemiMonthBegin + _offset = SemiMonthBegin # type: Callable offset1 = _offset() offset2 = _offset(2) diff --git a/setup.cfg b/setup.cfg index 462e79dae1039..7f08e704e4a9e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -217,8 +217,5 @@ ignore_errors=True [mypy-pandas.tests.test_base] ignore_errors=True -[mypy-pandas.tests.tseries.offsets.test_offsets] -ignore_errors=True - [mypy-pandas.tests.tseries.offsets.test_yqm_offsets] ignore_errors=True From 277cfdeba5d3d120ccb847ccd82aec3413407637 Mon Sep 17 00:00:00 2001 From: galunid Date: Fri, 25 Oct 2019 23:51:49 +0200 Subject: [PATCH 2/4] Apply requested fixes --- pandas/tests/tseries/offsets/test_offsets.py | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index f132b0eaee788..f1d03d15335cc 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 Callable, Dict, List, Tuple, Union +from typing import Dict, List, Tuple, Type, Union import numpy as np import pytest @@ -93,7 +93,7 @@ def test_to_M8(): class Base: - _offset = None # type: Union[BusinessHour, CustomBusinessHour, Callable] + _offset = None # type: Type[DateOffset] d = Timestamp(datetime(2008, 1, 2)) timezones = [ @@ -660,7 +660,7 @@ def test_eq(self): class TestBusinessDay(Base): - _offset = BDay # type: Callable + _offset = BDay def setup_method(self, method): self.d = datetime(2008, 1, 1) @@ -741,7 +741,7 @@ def test_onOffset(self): for offset, d, expected in tests: assert_onOffset(offset, d, expected) - apply_cases = [] # type: List[Tuple[int, Dict[datetime, datetime]]] + apply_cases = [] # type: List apply_cases.append( ( BDay(), @@ -2629,10 +2629,10 @@ def test_onOffset(self, case): offset, d, expected = case assert_onOffset(offset, d, expected) - apply_cases = [] + apply_cases = [] # type: List apply_cases.append( ( - 1 * CDay(), + CDay(), { datetime(2008, 1, 1): datetime(2008, 1, 2), datetime(2008, 1, 4): datetime(2008, 1, 7), @@ -2876,10 +2876,10 @@ def test_onOffset(self, case): offset, d, expected = case assert_onOffset(offset, d, expected) - apply_cases = [] + apply_cases = [] # type: List apply_cases.append( ( - 1 * CBMonthEnd(), + CBMonthEnd(), { datetime(2008, 1, 1): datetime(2008, 1, 31), datetime(2008, 2, 7): datetime(2008, 2, 29), @@ -3025,10 +3025,10 @@ def test_onOffset(self, case): offset, dt, expected = case assert_onOffset(offset, dt, expected) - apply_cases = [] + apply_cases = [] # type: List apply_cases.append( ( - 1 * CBMonthBegin(), + CBMonthBegin(), { datetime(2008, 1, 1): datetime(2008, 2, 1), datetime(2008, 2, 7): datetime(2008, 3, 3), @@ -3121,7 +3121,7 @@ def test_datetimeindex(self): class TestWeek(Base): - _offset = Week # type: Callable + _offset = Week d = Timestamp(datetime(2008, 1, 2)) offset1 = _offset() offset2 = _offset(2) @@ -3220,7 +3220,7 @@ def test_onOffset(self, weekday): class TestWeekOfMonth(Base): - _offset = WeekOfMonth # type: Callable + _offset = WeekOfMonth offset1 = _offset() offset2 = _offset(2) @@ -3320,7 +3320,7 @@ def test_onOffset(self, case): class TestLastWeekOfMonth(Base): - _offset = LastWeekOfMonth # type: Callable + _offset = LastWeekOfMonth offset1 = _offset() offset2 = _offset(2) @@ -3397,7 +3397,7 @@ def test_onOffset(self, case): class TestSemiMonthEnd(Base): - _offset = SemiMonthEnd # type: Callable + _offset = SemiMonthEnd offset1 = _offset() offset2 = _offset(2) @@ -3656,7 +3656,7 @@ def test_vectorized_offset_addition(self, klass): class TestSemiMonthBegin(Base): - _offset = SemiMonthBegin # type: Callable + _offset = SemiMonthBegin offset1 = _offset() offset2 = _offset(2) From cc7426a7726dc6e80519e90b8b6ea7a810e1f483 Mon Sep 17 00:00:00 2001 From: galunid Date: Sat, 26 Oct 2019 21:47:35 +0200 Subject: [PATCH 3/4] Apply fixes --- pandas/tests/tseries/offsets/test_offsets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index f1d03d15335cc..fc36c50506c67 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 Dict, List, Tuple, Type, Union +from typing import Dict, List, Type import numpy as np import pytest @@ -1698,7 +1698,7 @@ def test_opening_time(self, case): assert offset._next_opening_time(dt) == exp_next assert offset._prev_opening_time(dt) == exp_prev - apply_cases = [] # type: List[Tuple[int, Dict[datetime, datetime]]] + apply_cases = [] # type: List apply_cases.append( ( BusinessHour(), From 25cb051fc52e83e554549d34d5bf97965b829c03 Mon Sep 17 00:00:00 2001 From: galunid Date: Sat, 26 Oct 2019 21:51:07 +0200 Subject: [PATCH 4/4] Remove unused import --- pandas/tests/tseries/offsets/test_offsets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index fc36c50506c67..e435a6846a77e 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 Dict, List, Type +from typing import List, Type import numpy as np import pytest