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