-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: _concat_same_type method of EA #37817
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
TYP: _concat_same_type method of EA #37817
Conversation
@@ -1468,10 +1472,19 @@ def _get_combined_data( | |||
axis=1, | |||
) | |||
else: | |||
left = cast(Union["DatetimeArray", "TimedeltaArray"], left) | |||
right = cast(Union["DatetimeArray", "TimedeltaArray"], right) |
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.
the casting doesnt help?
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.
the casts as they stand give
pandas\core\arrays\interval.py:1478: error: List item 0 has incompatible type "Union[DatetimeArray, TimedeltaArray]"; expected "DatetimeArray" [list-item]
pandas\core\arrays\interval.py:1478: error: List item 0 has incompatible type "Union[DatetimeArray, TimedeltaArray]"; expected "TimedeltaArray" [list-item]
pandas\core\arrays\interval.py:1478: error: List item 1 has incompatible type "Union[DatetimeArray, TimedeltaArray]"; expected "DatetimeArray" [list-item]
pandas\core\arrays\interval.py:1478: error: List item 1 has incompatible type "Union[DatetimeArray, TimedeltaArray]"; expected "TimedeltaArray" [list-item]
and would need to be changed. I can't immediately see what guarentees we have that justify the casts.
the 'ignore' is a fix later properly. (I guess the function signature here maybe incorrect, but not checked) and will circle back to this after getting started on the other EA methods as a precursor to adding type annotations to #35259
If this is not a false positive, it needs more investigation before casting to silence the mypy errors.
can you merge master |
…_type-method-of-ea
pandas/core/arrays/base.py
Outdated
@@ -37,6 +48,8 @@ | |||
|
|||
_extension_array_shared_docs: Dict[str, str] = dict() | |||
|
|||
ExtensionArrayT = TypeVar("ExtensionArrayT", bound="ExtensionArray") |
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 might have asked before, but can you explain again why this is needed, and the "ExtensionArray"
as string version doesn't work?
(I think I mentioned this before, but IMO we should have better documentation about the specific patterns we are using in pandas in our contributing guides)
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 I mentioned this before, but IMO we should have better documentation about the specific patterns we are using in pandas in our contributing guides)
these are not specific patterns to pandas. https://mypy.readthedocs.io/en/stable/generics.html#generic-functions and https://mypy.readthedocs.io/en/stable/generics.html#generic-methods-and-generic-self
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 might have asked before, but can you explain again why this is needed, and the
"ExtensionArray"
as string version doesn't work?
I do recall explaining it in the past (obviously didn't do a good job) won't bother with a generic explanation again, and next time I come across a concrete example of why this is needed will cc you in.
thanks @simonjayhawkins |
some overlap with #37816