-
-
Notifications
You must be signed in to change notification settings - Fork 154
Use default in TypeVar so Series defaults to Series[Any], and Index to Index[Any]
#1232
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
Conversation
1a6dbd7 to
f63956a
Compare
default in TypeVar so Series defaults to Series[Any], and Index to Index[Any]default in TypeVar so Series defaults to Series[Any], and Index to Index[Any]
|
I'm fine with this. Need to run |
|
cool, thanks! there's a couple of test failures I haven't figured out, will investigate |
b0d5713 to
e67aaa9
Compare
Dr-Irv
left a comment
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.
Looks OK so far.
| ) -> Iterator[tuple[ByT, Series[S1]]]: ... | ||
|
|
||
| _TT = TypeVar("_TT", bound=Literal[True, False]) | ||
| _TT = TypeVar("_TT", bound=Literal[True, False], default=Literal[True]) |
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.
I'm a bit surprised that you didn't have to change the import of TypeVar to come from typing_extensions here since you are using the default feature.
|
i think there might be an issue with mypy here, have reported python/mypy#19182 |
tests/test_frame.py
Outdated
| assert_type( | ||
| df_multi_level_cols2.stack([0, 1]), | ||
| Union[pd.DataFrame, "pd.Series[Any]"], | ||
| Union[pd.DataFrame, "pd.Series"], |
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.
Any of the places where we used to have "pd.Series[Any]" that you changed to "pd.Series" can have the quotes removed. The quotes were there because of the [Any] part.
default in TypeVar so Series defaults to Series[Any], and Index to Index[Any]default in TypeVar so Series defaults to Series[Any], and Index to Index[Any]
Dr-Irv
left a comment
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 @MarcoGorelli . Nice new feature of typing to include.
|
yay, thanks! |
bit of an experiment
closes #1133
I saw that NumPy follow this pattern, for example here:
https://github.com/numpy/numpy/blob/3363b38d99f87601869c2c9d68c2b16e54509675/numpy/__init__.pyi#L788-L792
and they import
TypeVarfromtyping_extensions(which is a dependency of mypy anyway)This would close 1133 for free, and I think improve ergonomics