Home | History | Annotate | Download | only in test
      1 """
      2 Some correct syntax for variable annotation here.
      3 More examples are in test_grammar and test_parser.
      4 """
      5 
      6 from typing import no_type_check, ClassVar
      7 
      8 i: int = 1
      9 j: int
     10 x: float = i/10
     11 
     12 def f():
     13     class C: ...
     14     return C()
     15 
     16 f().new_attr: object = object()
     17 
     18 class C:
     19     def __init__(self, x: int) -> None:
     20         self.x = x
     21 
     22 c = C(5)
     23 c.new_attr: int = 10
     24 
     25 __annotations__ = {}
     26 
     27 
     28 @no_type_check
     29 class NTC:
     30     def meth(self, param: complex) -> None:
     31         ...
     32 
     33 class CV:
     34     var: ClassVar['CV']
     35 
     36 CV.var = CV()
     37