-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the current behaviour
Whether we use from __future__ import annotations
or not radically changes the scoping rules. I suppose this is designed this way. But pyright
is not in agreement with mypy
on this particular topic.
To Reproduce
This typechecks correctly with pyright
(but mypy
complains about F
being not a valid type). I'm not saying it shouldn't, just saying it looks like there are some discrepancies in how mypy
and pyright
handle this specific (and totally theoretical) case.
from __future__ import annotations
class C:
F = b'not a valid type'
def f(self) -> F:
return F()
class F:
...
Expected behavior
I'd expect pyright
to have the same behaviour as mypy
(or the other way around, I don't care). From the perspective of a developer of static analysis tools, I don't know which behaviour is the "right way". I've read about all the typing PEPs and couldn't find a clear and definitive answer.
Thanks
PS, this is not a bug report.