python / python/mypy

false positive flags superclass method as undefined

Open
#17,322 1 comment 1 reaction 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

Bug Report

mypy incorrectly complains that the __setstate__ method is undefined in the multiprocessing.Queue

Here is where __setstate__ is defined:

https://github.com/python/cpython/blob/0480fd628a33351be868460c6febc09541ac722c/Lib/multiprocessing/queues.py#L62

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.12&flags=verbose%2Ccheck-untyped-defs&gist=31e5a18f3d712b3e9991216bb8013bd7

Expected Behavior

I expected no typechecking errors.

Actual Behavior

If you run the included gist above you will see:

main.py:12: error: "__setstate__" undefined in superclass  [misc]
Found 1 error in 1 file (checked 1 source file)

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

Run the linked mypy-play reproduction with Python 3.12 and the listed flags, then compare the diagnostic with the setstate definition linked in CPython's Lib/multiprocessing/queues.py. Trace the superclass-method lookup that produces the undefined error and add or update a regression test for the gist case. Done means the reproduction reports no type-checking errors without introducing regressions.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.