python / python/typeshed

multiprocessing.Value.value needs to be defined

Open
#10,319 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

The following sample code:

import multiprocessing as mp
x = mp.Value( 'i', 0 )
print( f'{x.value=}' )
x.value = 1
print( f'{x.value=}' )

Produces this output when run:

x.value=0
x.value=1

But mypy complains:

mypy_bug_multiprocessing_value.py:3: error: "SynchronizedBase[Any]" has no attribute "value"  [attr-defined]
mypy_bug_multiprocessing_value.py:4: error: "SynchronizedBase[Any]" has no attribute "value"  [attr-defined]
mypy_bug_multiprocessing_value.py:5: error: "SynchronizedBase[Any]" has no attribute "value"  [attr-defined]

Python version: Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
mypy version: mypy==1.3.0

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

Start by locating the typeshed stub for multiprocessing.Value and the SynchronizedBase definition referenced in the mypy error. Compare the declared interface with the sample's .value reads and assignment, then add or update the relevant stub coverage and a regression check if the repository has an applicable test pattern. Done means the sample type-checks without attr-defined errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.