python / python/mypy

Wrong SynchronizedArray type

Open
#17,577 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Since mypy 1.11.0, mypy does not infer the right type for multiprocessing.Array

To Reproduce

With mypy 1.10.1: https://mypy-play.net/?mypy=1.10.1&python=3.12&gist=6160e18513148cff1b8a4e1b261aab8b

With mypy 1.11.0: https://mypy-play.net/?mypy=1.11.0&python=3.12&gist=619ce7173b980fb7c3533a1cc60f8304

Expected Behavior
Array(c_double) should be recognized as SynchronizedArray[c_double] and Array(c_float) should be recognized as SynchronizedArray[c_float]

Actual Behavior

Both are recognized as SynchronizedArray[float].

Your Environment

N/A, cf. mypy-play links above.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the difference using the two mypy-play links and compare the inferred types for multiprocessing.Array with c_double and c_float. Trace the regression in mypy's handling of these calls and add a regression test; done means each array is inferred with its corresponding SynchronizedArray type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.