python / python/mypy

`[type-abstract]` reports with a `tuple` when the actual type is a `dict`

Open
#17,399 2 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

Bug Report, To Reproduce, & Actual Behaviour

See mypy Playground

from abc import ABC, abstractmethod

class Abstract(ABC):
    @abstractmethod
    def method(self) -> None: ...

class Unimplemented(Abstract): ...

class Parent:
    others: dict[str, type[Abstract]]

class Child(Parent):
    others = {"abstract": Unimplemented}  # E: Only concrete class can be given where "tuple[str, type[Abstract]]" is expected  [type-abstract]

Expected Behavior

Reports the error message with "dict[str, type[Abstract]]".

Your Environment

  • Mypy version used: 1.10
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10, 3.12

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 with the linked mypy Playground reproduction under Python 3.12 and strict mode, then trace the source of the [type-abstract] diagnostic and its displayed inferred type. Done means the same example reports dict[str, type[Abstract]] rather than tuple[str, type[Abstract]], with behavior checked against the stated Python versions.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.