Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jonathanslenders opened this issue Jul 25, 2020 · 2 comments
Closed

Comments

@jonathanslenders
Copy link

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'
PrettyWood added a commit to PrettyWood/pydantic that referenced this issue Dec 24, 2020
PrettyWood added a commit to PrettyWood/pyflakes that referenced this issue Dec 25, 2020
PrettyWood added a commit to PrettyWood/pyflakes that referenced this issue Dec 25, 2020
PrettyWood added a commit to PrettyWood/pyflakes that referenced this issue Dec 25, 2020
samuelcolvin added a commit to pydantic/pydantic that referenced this issue Jan 2, 2021
* fix: force need of `update_forward_refs` in recursive models

closes #1201

* fix: lint issue (false positive)

PyCQA/pyflakes#567

* chore: avoid if statement for coverage

* fix linting

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
@asottile
Copy link
Member

this as inadvertently fixed by #754

@jonathanslenders
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants