Classes defined inside a function aren't recognised as valid type annotations
The following code triggers a Pytype error Invalid type annotation 'A' [invalid-annotation]. Name 'A' is not defined:
def some_function():
class A:
pass
class B:
a: A = A()
This behaviour is incorrect as A is clearly defined and in-scope for use in the type annotation.
If instead the two classes are defined at the module level, outside of the body of a function, there is (correctly) no error raised:
class A:
pass
class B:
a: A = A()
This issue exists in pytype==2020.06.26 on MacOS, with Python 3.7.
I just checked and this issue is not present in pytype==2020.4.22 but is present in pytype==2020.5.13 (and all later releases), so it must have been introduced between the two.
The bug appears to have been introduced by https://github.com/google/pytype/commit/b57cc280959d570ec9607ae029597793fff703cf.
Unassigning myself since I'm not actively working on this.