Skip to content

Conversation

@RomanMIzulin
Copy link
Contributor

Before processing further, here a little snippet how it could look like.

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

🙏 Please, if you or your company finds dry-python valuable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.


asyncwithanyio.create_task_group() astg:
containers_t=tuple(containers)
results: list[IOResult] =len(containers_t)*[IOResult(None)]
Copy link
Member

Choose a reason for hiding this comment

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

you can use a dict[int, IOResult[R, E]] here instead. Where int is the index of the running task.


fori, coroinenumerate(containers_t):
tg.start_soon(run_task, coro, i)
returntuple(results)
Copy link
Member

Choose a reason for hiding this comment

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

and return a tuple sorted by keys of the this dict.

])
deftest_gather(containers, expected):
"""Test partition function."""
assertgather(containers) ==expected
Copy link
Member

Choose a reason for hiding this comment

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

This should not be possible. You cannot mix Future and FutureResult in one operation without an explicit cast.

Copy link
Member

Choose a reason for hiding this comment

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

(from mypy's point of view, I mean)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It is not supposed to mix IO operations that can and can not fail? Or it is just mypy limitation?

@@ -1,4 +1,5 @@
fromreturns.methods.condimportcondascond
fromreturns.methods.gatherimportgatherasgather
Copy link
Member

Choose a reason for hiding this comment

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

Let's create a new file: async_.py and put it there.

Copy link
ContributorAuthor

@RomanMIzulinRomanMIzulinNov 24, 2024

Choose a reason for hiding this comment

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

Is naming of the method good(gather)?

Copy link
Member

Choose a reason for hiding this comment

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

yeap

@codecov
Copy link

codecovbot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (82ef3ef) to head (5bab4bc).
Report is 317 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #1966 +/- ## ========================================== Coverage 100.00% 100.00% ========================================== Files 80 82 +2 Lines 2485 2592 +107 Branches 437 45 -392 ========================================== + Hits 2485 2592 +107 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@RomanMIzulin@sobolevn@romanmatveevsky