Skip to content

CLN: fix mypy errors in pandas\tests\indexes\interval\test_base.py #28926 #28961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/tests/indexes/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gc
from typing import Optional, Type

import numpy as np
import pytest
Expand Down Expand Up @@ -30,7 +31,7 @@
class Base:
""" base class for index sub-class tests """

_holder = None
_holder = None # type: Optional[Type[Index]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be Optional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should keep the Optional otherwise when we use 3.6 type annotations we'll get
pandas\tests\indexes\common.py:34: error: Incompatible types in assignment (expression has type "None", variable has type "Type[Index]")

The Optional should only be excluded where we have added something = None # type: ... for the purpose of type checking.

In this case _holder was set to None before the type annotation was added.

so when we move to 3.6, we will change to
_holder: Optional[Type[Index]] = None
whereas if the initialisation was purely added for the type annotations we would change to just
_holder: Type[Index]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the latter what we actually want here though? OK to change to 36 annotation now on this PR since 35 CI should be dropped within the next few days

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the latter what we actually want here though?

IMO out of scope here

but to answer your question, in general, with 3.6, we could reduce the number of assert <some_variable> is not None that are sometimes needed when class attributes are initialised to None, but we would need to evaluate on a case by case basis.

OK to change to 36 annotation now on this PR since 35 CI should be dropped within the next few days

i'm not sure a good reason to block since this is not guaranteed.

_compat_props = ["shape", "ndim", "size", "nbytes"]

def test_pickle_compat_construction(self):
Expand Down
21 changes: 0 additions & 21 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -148,33 +148,12 @@ ignore_errors=True
[mypy-pandas.tests.extension.json.test_json]
ignore_errors=True

[mypy-pandas.tests.indexes.datetimes.test_datetimelike]
ignore_errors=True

[mypy-pandas.tests.indexes.interval.test_base]
ignore_errors=True

[mypy-pandas.tests.indexes.interval.test_interval_tree]
ignore_errors=True

[mypy-pandas.tests.indexes.period.test_period]
ignore_errors=True

[mypy-pandas.tests.indexes.test_base]
ignore_errors=True

[mypy-pandas.tests.indexes.test_category]
ignore_errors=True

[mypy-pandas.tests.indexes.test_numeric]
ignore_errors=True

[mypy-pandas.tests.indexes.test_range]
ignore_errors=True

[mypy-pandas.tests.indexes.timedeltas.test_timedelta]
ignore_errors=True

[mypy-pandas.tests.indexing.test_loc]
ignore_errors=True

Expand Down