Skip to content

Bad error message: mypy reports 'Name is not defined' when using an object member as super class of another class #8603

Open
@sandrinr

Description

@sandrinr

Consider the following valid Python 3 code:

class A():
    pass

class B():
    def __init__(self):
        self.a = A

b = B()

class C(b.a):
    pass

Actual behavior:
Mypy will report Name 'b.a' is not defined on the line class C(b.a):.

Expected behavior:
No error reported by Mypy.

Python version: 3.8.2
Mypy version: 0.770 (master not checked)
Flags: no flags

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions