Skip to content

TYP: annotate core.algorithms #33944

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
merged 2 commits into from
May 6, 2020

Conversation

jbrockmendel
Copy link
Member

No description provided.

@jreback jreback added the Typing type annotations, mypy/pyright type checking label May 5, 2020
@jreback jreback added this to the 1.1 milestone May 5, 2020
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm. Like the dtype changes for sure

@simonjayhawkins

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @jbrockmendel generally lgtm. comments not blockers

def _reconstruct_data(values, dtype, original):
def _reconstruct_data(
values: ArrayLike, dtype: DtypeObj, original: AnyArrayLike
) -> ArrayLike:
Copy link
Member

Choose a reason for hiding this comment

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

ArrayLike is a typevar. is the return type here always the same as the type of values? or dependant on dtype.

maybe just expand on the prose in the docstring till this bites us.

Copy link
Member Author

Choose a reason for hiding this comment

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

ArrayLike is a typevar. is the return type here always the same as the type of values? or dependant on dtype.

Yikes, I think I've been using it incorrectly in a lot of places then. Ive been using it as a synonym for Union[np.ndarray, ExtensionArray]. I guess I'll do a dedicated pass through the code to weed out those mis-usages

Copy link
Member

Choose a reason for hiding this comment

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

Ive been using it as a synonym for Union[np.ndarray, ExtensionArray]

This is OK if the alias only appears once in the function signature/return.

once it appears twice, then they are bound.

original : ndarray-like
values : np.ndarray or ExtensionArray
dtype : np.ndtype or ExtensionDtype
original : AnyArrayLike
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, values and dtype are 'expanded' aliases, do the same for AnyArrayLike?

again maybe more prose, is Index only allowed with bool_dtype? what about Series?

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAICT it can be Index or Series regardless of dtype, whatever was passed to the top-level fucntion

@jbrockmendel
Copy link
Member Author

comments not blockers

I'd like to push this through and handle comments in the next pass, since this is green and the CI is currently failing. (ditto for #33935)

@simonjayhawkins simonjayhawkins merged commit 6cdd211 into pandas-dev:master May 6, 2020
@simonjayhawkins
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the typ-algos branch May 6, 2020 19:01
rhshadrach pushed a commit to rhshadrach/pandas that referenced this pull request May 10, 2020
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