Skip to content
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

py3-prep: fix filter with list comprehensions #34

Merged
merged 1 commit into from Mar 22, 2020

Conversation

bhipple
Copy link
Contributor

@bhipple bhipple commented Mar 22, 2020

In py2, filter returned a list; in py3, it returns an iterator, which can't be indexed.

Per upstream guidelines [1], while it is possible to just add a list() cast,
it's more idiomatic to use a list comprehension for filtering. This is more
pythonic regardless, and still py2 compatible.

Partial progress towards #29

CC @grahamc @AmineChikhaoui

[1] https://docs.python.org/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists

In py2, filter returned a list; in py3, it returns an iterator, which can't be indexed.

Per upstream guidelines [1], while it is possible to just add a `list()` cast,
it's more idiomatic to use a list comprehension for filtering. This is more
pythonic regardless, and still py2 compatible.

Partial progress towards NixOS#29

[1] https://docs.python.org/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists
@bhipple
Copy link
Contributor Author

bhipple commented Mar 22, 2020

Note: this PR contains manual changes! As before, I have built the plugin (plus other 2to3 transformations) with the lastest master commit of nixops on master in py3 and provisioned my AWS cluster successfully to test.

@grahamc grahamc merged commit dff6c9e into NixOS:master Mar 22, 2020
@bhipple bhipple deleted the py3/filter branch March 22, 2020 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants