Skip to content

stub for multiprocessing map_async returns the wrong type #3377

@nbrahms

Description

@nbrahms

👋 Filing this as I noticed the stub for map_async was returning too many depths of nested lists.

Here's a simple script to reproduce:

from multiprocessing.pool import Pool
from typing import List

def double(x: int) -> int:
    return 2 * x

def parallel_double(xx: List[int]) -> List[int]:
    with Pool(len(xx)) as pool:
        return pool.map_async(double, xx).get()

print(parallel_double([1, 2]))

To sanity check that the type annotations as written are correct:

$ python3 map_async.py
[2, 4]

And here's the output of mypy:

$ mypy map_async.py
map_async.py:9: error: Incompatible return value type (got "List[List[int]]", expected "List[int]")
Found 1 error in 1 file (checked 1 source file)

I'm going to see if I can get a contribution environment up and running quickly and submit a PR to fix.

Edit: typo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions