Skip to content

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Nov 27, 2022

Return early in the case of len(data) == 0, thereby avoiding needing a long else clause. Also clean type hints.

EDIT: The PR looks a bit messy at first sight, but it's mostly just dedenting stuff. Checking "Hide whitespace" makes the PR much clearer, as suggested by @MarcoGorelli in #49921.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Nice, good to see this fixing a typing issue!

else:
index = default_index(lengths[0])
if have_series:
assert index is not None # for mypy
Copy link
Member

Choose a reason for hiding this comment

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

is the # for mypy comment still necessary?

Copy link
Contributor Author

@topper-123 topper-123 Nov 27, 2022

Choose a reason for hiding this comment

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

Good catch, the whole line is actually unnecessary as index is never None here. I'll remove it.

Copy link
Member

Choose a reason for hiding this comment

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

😄 yeah sorry I meant the whole line

@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Nov 27, 2022
@topper-123
Copy link
Contributor Author

Updated.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Thanks @topper-123 !

@MarcoGorelli MarcoGorelli merged commit b973162 into pandas-dev:main Nov 28, 2022
@topper-123 topper-123 deleted the clean_extract_index branch November 28, 2022 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants