Describe the bug
I'm using type annotations in a dataclass. While other annotations work as expected, pyright is raising a problem when an annotation is used with the same type as the dataclass
To Reproduce
See screenshot
Expected behavior
No problem should be raised.
Screenshots or Code

VS Code extension or command-line
I am running pyright 1.0.69 as a VS Code extension
That's the correct behavior. If you try to execute this code in the python interpreter, it will generate an exception because the TimeWindow class is considered a forward declaration in this context. It's not yet defined when these annotations are encountered.
The correct workaround is to enclose the forward reference in quotes, as indicated in PEP 484. The python interpreter will then treat the annotation as a string literal value and won't generate an exception. The type checker is smart enough to parse the contents of the string literal.
Thanks Eric, I wasn't aware of that. I put the forward reference in quotes and now I don't see any warning so I assume it works.
Most helpful comment
That's the correct behavior. If you try to execute this code in the python interpreter, it will generate an exception because the TimeWindow class is considered a forward declaration in this context. It's not yet defined when these annotations are encountered.
The correct workaround is to enclose the forward reference in quotes, as indicated in PEP 484. The python interpreter will then treat the annotation as a string literal value and won't generate an exception. The type checker is smart enough to parse the contents of the string literal.