Skip to content

False positive in type annotation of recursive data structure. #567

@jonathanslenders

Description

@jonathanslenders
from typing import Dict

def test() -> None:
    class Tree(Dict[str, "Tree"]):
        def __missing__(self, key: str) -> "Tree":
            self[key] = Tree()
            return self[key]
/tmp/x.py:4:26 undefined name 'Tree'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions