Skip to content

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

Merged

Conversation

simonjayhawkins
Copy link
Member

some overlap with #37816

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Nov 13, 2020
@@ -1468,10 +1472,19 @@ def _get_combined_data(
axis=1,
)
else:
left = cast(Union["DatetimeArray", "TimedeltaArray"], left)
right = cast(Union["DatetimeArray", "TimedeltaArray"], right)
Copy link
Member

Choose a reason for hiding this comment

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

the casting doesnt help?

Copy link
Member Author

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.

@jreback jreback added this to the 1.2 milestone Nov 14, 2020
@jreback
Copy link
Contributor

jreback commented Nov 14, 2020

can you merge master

@@ -37,6 +48,8 @@

_extension_array_shared_docs: Dict[str, str] = dict()

ExtensionArrayT = TypeVar("ExtensionArrayT", bound="ExtensionArray")
Copy link
Member

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)

Copy link
Member Author

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

Copy link
Member Author

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.

@jreback jreback merged commit b00a17e into pandas-dev:master Nov 14, 2020
@jreback
Copy link
Contributor

jreback commented Nov 14, 2020

thanks @simonjayhawkins

@simonjayhawkins simonjayhawkins deleted the type-_concat_same_type-method-of-ea branch November 15, 2020 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants