Skip to content

Conversation

@fabridamicelli
Copy link

@fabridamicelli fabridamicelli commented Jul 30, 2024

First off: Thank you very much for this package! :)

Here's a little thing about type hints I found.
In essence the Sequece type is too restrictive. The function map can deal as is with any iterable.

Description

The type of the arg iterable should be a Iterable instead of Sequence.
Here's pyright hint:

pyright-error

And here's after the fix

pyright-noerror

@fabridamicelli
Copy link
Author

Here's an actually running example code:

import asyncio

from aiomultiprocess import Pool


async def f(i: int) -> int:
    await asyncio.sleep(0.1)
    return i


async def main():
    async with Pool() as p:
        vals_seq = [0, 1, 2]
        vals_iter = (i for i in range(3))

        print(await p.map(f, vals_seq))
        print(await p.map(f, vals_iter))


if __name__ == "__main__":
    asyncio.run(main())

pyright-noerror

which outputs:

out

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.

1 participant