-
-
Notifications
You must be signed in to change notification settings - Fork 150
BUG: Fix MultiIndex.dtypes (#597) #603
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
BUG: Fix MultiIndex.dtypes (#597) #603
Conversation
pandas-stubs/core/indexes/multi.pyi
Outdated
@property | ||
def dtype(self) -> np.dtype: ... | ||
@property | ||
def dtypes(self) -> pd.Series[Any]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably be tightened to pd.Series[numpy.dtype | pd.api.extensions.ExtensionDtype]
but that probably causes trouble (I don't think those classes are part of S1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With pd.Series[numpy.dtype | pd.api.extensions.ExtensionDtype]
mypy says
pandas-stubs/core/indexes/multi.pyi:73: error: Invalid type argument value for "Series" [type-var]
tests/test_indexes.py:862: error: Invalid type argument value for "Series" [type-var]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the dtype
of the returned Series
is object
, since it is a Series
of dtypes. You could try adding Dtype
to S1
in _typing.pyi
but that might break other things. If it doesn't break anything, then you could return Series[Dtype]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could try modifying S1
to include Dtype
, but if that doesn't work, then just have dtypes
return pd.Series
.
pandas-stubs/core/indexes/multi.pyi
Outdated
@property | ||
def dtype(self) -> np.dtype: ... | ||
@property | ||
def dtypes(self) -> pd.Series[Any]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the dtype
of the returned Series
is object
, since it is a Series
of dtypes. You could try adding Dtype
to S1
in _typing.pyi
but that might break other things. If it doesn't break anything, then you could return Series[Dtype]
It seems to work in the sense that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @johannes-mueller
* Fix MultiIndex.dtypes (pandas-dev#597) * Tighten the MultiIndex.dtypes return value to Dtype
assert_type()
to assert the type of any return value