Skip to content

"Invalid type" when using class attribute as type variable. #7052

Closed
@feluxe

Description

@feluxe

Are you reporting a bug, or opening a feature request?

A bug I guess. Please excuse me if I'm missing something here.

Code to reproduce the issue:

@dataclass
class Column:
    name: str


class Pg:
    Column = Column

pg = Pg()

@dataclass
class SearchToken:
    column: pg.Column

What is the actual behavior/output?

Mypy marks the last line as an error:

Invalid type mypackage.mymodule.pg

What is the behavior/output you expect?

Mypy not complaining about the last line or a better error message, that guides me somewhere to solve the given scenario. I feel kinda lost with this right now.

What are the versions of mypy and Python you are using?
Python 3.7.3
mypy 0.710

Do you see the same issue after installing mypy from Git master?
I couldn't get this to work with pipenv.

What are the mypy flags you are using?
I don't use any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions