Skip to content
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

pandas-dev#28926 Mypy fix/extension json array #28989

Closed
wants to merge 3 commits into from
Closed
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/extension/json/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import random
import string
import sys
from typing import Mapping

import numpy as np

Expand All @@ -27,7 +28,7 @@
class JSONDtype(ExtensionDtype):
type = abc.Mapping
name = "json"
na_value = UserDict()
Copy link
Member

Choose a reason for hiding this comment

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

@simonjayhawkins i know ive asked you this before, but why cant mypy figure this out on its own?

Copy link
Member

Choose a reason for hiding this comment

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

the revealed type for na_value is Revealed type is 'collections.UserDict[Any, Any]'.

mypy asks for more info to narrow the Any

na_value = UserDict() # type: Mapping[type, type]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think type should be used for subscripts; I think just Mapping[str, Any] is fine

Copy link
Member

Choose a reason for hiding this comment

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

will need to change to py3.6 syntax.


@classmethod
def construct_array_type(cls):
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ ignore_errors=True
[mypy-pandas.tests.extension.decimal.test_decimal]
ignore_errors=True

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

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

Expand Down