Skip to content

Generated classes does not work with forward references #1701

Description

@MeGotsThis

It seems mypy has trouble with generated classes such as NamedTuple.

a.py:

import b
from typing import Any, NamedTuple

class A:
    def a(self, b: 'b.B') -> str:
        return 'a'

ATuple = NamedTuple('ATuple', [('a', Any)])

b.py:

import a

class B:
    def b(self, a: 'a.A') -> str:
        return 'b'

    def aWithTuple(self, atuple: 'a.ATuple') -> str:
        return 'a'

mypy a.py output

a.py:1: note: In module imported here:
b.py: note: In function "aWithTuple":
b.py:7: error: Invalid type "a.ATuple"

mypy b.py works just fine

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions