-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Convert Unions to TypeVar #26588
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
Convert Unions to TypeVar #26588
Conversation
@WillAyd take a look, there are some more Union but they error, I will look at them later. |
Looks good at first glance. FilePathOrBuffer probably makes sense to keep a Union if that’s what is causing issues as we don’t really use those in containers and typically doesn’t care to maintain their type in generic functions (I.e. we intentionally convert from say strings to buffers) |
@WillAyd got some failing tests of travis, even with just these changes. It doesn't makes much sense to why it's failing, you can check it here: https://travis-ci.com/vaibhavhrt/pandas/jobs/204447635 |
Might have to merge master to resolve but yes unrelated to this PR |
lgtm. this is a draft PR, can you update; ping on green (and merge master). |
@jreback I still have a few things to do in this PR. I mark is ready once I am done. |
Codecov Report
@@ Coverage Diff @@
## master #26588 +/- ##
===========================================
- Coverage 91.88% 41.78% -50.11%
===========================================
Files 174 174
Lines 50694 50661 -33
===========================================
- Hits 46581 21167 -25414
- Misses 4113 29494 +25381
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26588 +/- ##
==========================================
- Coverage 91.88% 91.87% -0.01%
==========================================
Files 174 174
Lines 50694 50694
==========================================
- Hits 46581 46577 -4
- Misses 4113 4117 +4
Continue to review full report at Codecov.
|
@jreback you can review now. Commits got little messed up when I was trying to delete one of my commits, but I guess that should not be problem. |
I think Dtype is fine as a Union - we use all of those interchangeably.
I think it’s a mistake for DatetimeLikeScalar to be a Type - maybe should make that a TypeVar instead and Update annotation where used to be Type[DatetimeLikeScalar]
…Sent from my iPhone
On Jun 6, 2019, at 1:58 PM, Vaibhav Vishal ***@***.***> wrote:
@vaibhavhrt commented on this pull request.
In pandas/_typing.py:
> @@ -11,12 +11,13 @@
from pandas.core.dtypes.generic import (
ABCExtensionArray, ABCIndexClass, ABCSeries, ABCSparseSeries)
-AnyArrayLike = Union[ABCExtensionArray,
- ABCIndexClass,
- ABCSeries,
- ABCSparseSeries,
- np.ndarray]
-ArrayLike = Union[ABCExtensionArray, np.ndarray]
+AnyArrayLike = TypeVar('AnyArrayLike',
OK, Remaining types are:
DatetimeLikeScalar = Type[Union[Period, Timestamp, Timedelta]]
Dtype = Union[str, np.dtype, ExtensionDtype]
FilePathOrBuffer = Union[str, Path, IO[AnyStr]]
Union in DatetimeLikeScalar is nested don't know if it should be converted to TypeVar
Converting Dtype to TypeVar starts giving errors.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
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 think this looks good - over to @jreback
thanks @vaibhavhrt |
git diff upstream/master -u -- "*.py" | flake8 --diff