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

Port reporting #6195

Merged
merged 1 commit into from Jul 20, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Jul 19, 2018

Part of #6062

map(lambda x, y: x or y, element, ('', None, None, False))
# zip_longest assumes None for missing values, so this generator will pick the default for those.
default_values = ('', None, None, False)
(text, detail, detail_id, detail_initially_visible) = (x or y for x, y in zip_longest(element, default_values))

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Jul 19, 2018

Contributor

This was tricky. In Py2, map() defaults to None when zipping like this and one of the iterables in shorter. In Py3, it no longer does that, so we have to use zip_longest().

I tried to make this more readable with the default_values variable and converting to a generator.

I don't think there's a unit test, but every pants goal fails when this piece is broken, so I think it's good to go.

This comment has been minimized.

@stuhood

stuhood Jul 19, 2018

Member

Yep, sounds reasonable. Thanks!

map(lambda x, y: x or y, element, ('', None, None, False))
# zip_longest assumes None for missing values, so this generator will pick the default for those.
default_values = ('', None, None, False)
(text, detail, detail_id, detail_initially_visible) = (x or y for x, y in zip_longest(element, default_values))

This comment has been minimized.

@stuhood

stuhood Jul 19, 2018

Member

Yep, sounds reasonable. Thanks!

@stuhood stuhood merged commit 6370c6c into pantsbuild:master Jul 20, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:port-reporting branch Jul 22, 2018

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment