Join of two type concrete type objects may be considered abstract

Open
#3,115 1 comment 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
devtools

Research direction

Start with the reproducer in the issue and inspect how mypy computes joins of callable type objects representing A and B. Determine whether t0 should be accepted without the abstract-class error, and assess whether the same behavior needs correction for meets.

Written by the indexing model from the issue text.

Description

bug false-positive priority-1-normal topic-join-v-union

Mypy complains about the following code even though it looks fine:

from abc import abstractmethod

class Base:
    @abstractmethod
    def f(self) -> None: pass
class A(Base):
    def f(self) -> None: pass
class B(Base):
    def f(self) -> None: pass

t = [A, B]

t[0]()  # Cannot instantiate abstract class 'Base' with abstract attribute 'f'

It looks like the join of two callables representing type objects should perhaps be Type[x] instead of another callable, since mypy basically assumes that a callable represents a specific type object, not something that can also be any subclass. The same issue probably applies to meets as well.

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

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.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.