Skip to content

Error accessing named tuple defined within import cycle #3054

Description

@JukkaL

Mypy doesn't recognize access to a named tuple defined in another module within an import cycle, if the other module is processed later than the module that contains the reference to the named tuple.

Example:

# a.pyfromcollectionsimportnamedtuplefrombimportfN=namedtuple('N', 'a')
# b.pyimportadeff(x: a.N) ->None: ... # Invalid type "a.N"

A potential fix is to process references to types in a later phase of semantic analysis than type definitions.

This is related to #3016.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions