Skip to content

Commit

Permalink
fixed mypy errors in mypy-pandas.tests.extension.decimal.test_decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
SaturnFromTitan committed Feb 6, 2020
1 parent 935b6f4 commit 8f13e39
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
19 changes: 15 additions & 4 deletions pandas/tests/extension/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@


class BaseExtensionTests:
# can't use staticmethod() as this confuses mypy
@staticmethod
def assert_equal(left, right, **kwargs):
return tm.assert_equal(left, right, **kwargs)

assert_equal = staticmethod(tm.assert_equal)
assert_series_equal = staticmethod(tm.assert_series_equal)
assert_frame_equal = staticmethod(tm.assert_frame_equal)
assert_extension_array_equal = staticmethod(tm.assert_extension_array_equal)
@staticmethod
def assert_series_equal(left, right, *args, **kwargs):
return tm.assert_series_equal(left, right, *args, **kwargs)

@staticmethod
def assert_frame_equal(left, right, *args, **kwargs):
return tm.assert_frame_equal(left, right, *args, **kwargs)

@staticmethod
def assert_extension_array_equal(left, right, *args, **kwargs):
return tm.assert_extension_array_equal(left, right, *args, **kwargs)
8 changes: 5 additions & 3 deletions pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def data_for_grouping():


class BaseDecimal:
def assert_series_equal(self, left, right, *args, **kwargs):
@staticmethod
def assert_series_equal(left, right, *args, **kwargs):
def convert(x):
# need to convert array([Decimal(NaN)], dtype='object') to np.NaN
# because Series[object].isnan doesn't recognize decimal(NaN) as
Expand All @@ -88,7 +89,8 @@ def convert(x):
tm.assert_series_equal(left_na, right_na)
return tm.assert_series_equal(left[~left_na], right[~right_na], *args, **kwargs)

def assert_frame_equal(self, left, right, *args, **kwargs):
@staticmethod
def assert_frame_equal(left, right, *args, **kwargs):
# TODO(EA): select_dtypes
tm.assert_index_equal(
left.columns,
Expand All @@ -103,7 +105,7 @@ def assert_frame_equal(self, left, right, *args, **kwargs):
decimals = (left.dtypes == "decimal").index

for col in decimals:
self.assert_series_equal(left[col], right[col], *args, **kwargs)
BaseDecimal.assert_series_equal(left[col], right[col], *args, **kwargs)

left = left.drop(columns=decimals)
right = right.drop(columns=decimals)
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ ignore_errors=True
[mypy-pandas.tests.arithmetic.test_datetime64]
ignore_errors=True

[mypy-pandas.tests.extension.decimal.test_decimal]
ignore_errors=True

[mypy-pandas.tests.extension.json.test_json]
ignore_errors=True

Expand Down

0 comments on commit 8f13e39

Please sign in to comment.