Skip to content

Replace redundant list comprehension with generator #3040

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 3 commits into from
May 14, 2025

Conversation

DimitriPapadopoulos
Copy link
Contributor

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.rst
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@DimitriPapadopoulos DimitriPapadopoulos marked this pull request as ready for review May 6, 2025 20:22
@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label May 6, 2025
dstansby
dstansby previously approved these changes May 8, 2025
@dstansby dstansby enabled auto-merge (squash) May 8, 2025 11:41
x
async for x in create_hierarchy(
store=store, nodes={"node": new_metadata}, overwrite=False
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CI fails with:

FAILED tests/test_group.py::test_create_hierarchy_existing_nodes[zarr2-async-array-memory] - TypeError: 'async_generator' object is not iterable
FAILED tests/test_group.py::test_create_hierarchy_existing_nodes[zarr2-async-group-memory] - TypeError: 'async_generator' object is not iterable
FAILED tests/test_group.py::test_create_hierarchy_existing_nodes[zarr3-async-array-memory] - TypeError: 'async_generator' object is not iterable
FAILED tests/test_group.py::test_create_hierarchy_existing_nodes[zarr3-async-group-memory] - TypeError: 'async_generator' object is not iterable

I think I need to change tuple( into await tuple(:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this cannot work. There is no such thing as a "tuple comprehension":
Aggregating an async generator to a tuple

auto-merge was automatically disabled May 8, 2025 12:12

Head branch was pushed to by a user without write access

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the PYL-R1728 branch 2 times, most recently from 273f16a to 4db0587 Compare May 8, 2025 12:27
@dstansby dstansby dismissed their stale review May 8, 2025 14:14

PR updated since review

There is no such thing as a "tuple comprehension":
https://stackoverflow.com/questions/52285419/aggregating-an-async-generator-to-a-tuple#52285420

Fixes CI error:
FAILED tests/test_group.py::test_create_hierarchy_existing_nodes[zarr2-async-array-memory] - TypeError: 'async_generator' object is not iterable
@dstansby dstansby enabled auto-merge (squash) May 14, 2025 18:12
@dstansby dstansby merged commit aa33415 into zarr-developers:main May 14, 2025
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs release notes Automatically applied to PRs which haven't added release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants