1 | n/a | |
---|
2 | n/a | |
---|
3 | n/a | """ |
---|
4 | n/a | The module for testing variable annotations. |
---|
5 | n/a | Empty lines above are for good reason (testing for correct line numbers) |
---|
6 | n/a | """ |
---|
7 | n/a | |
---|
8 | n/a | from typing import Optional |
---|
9 | n/a | |
---|
10 | n/a | __annotations__[1] = 2 |
---|
11 | n/a | |
---|
12 | n/a | class C: |
---|
13 | n/a | |
---|
14 | n/a | x = 5; y: Optional['C'] = None |
---|
15 | n/a | |
---|
16 | n/a | from typing import Tuple |
---|
17 | n/a | x: int = 5; y: str = x; f: Tuple[int, int] |
---|
18 | n/a | |
---|
19 | n/a | class M(type): |
---|
20 | n/a | |
---|
21 | n/a | __annotations__['123'] = 123 |
---|
22 | n/a | o: type = object |
---|
23 | n/a | |
---|
24 | n/a | (pars): bool = True |
---|
25 | n/a | |
---|
26 | n/a | class D(C): |
---|
27 | n/a | j: str = 'hi'; k: str= 'bye' |
---|
28 | n/a | |
---|
29 | n/a | from types import new_class |
---|
30 | n/a | h_class = new_class('H', (C,)) |
---|
31 | n/a | j_class = new_class('J') |
---|
32 | n/a | |
---|
33 | n/a | class F(): |
---|
34 | n/a | z: int = 5 |
---|
35 | n/a | def __init__(self, x): |
---|
36 | n/a | pass |
---|
37 | n/a | |
---|
38 | n/a | class Y(F): |
---|
39 | n/a | def __init__(self): |
---|
40 | n/a | super(F, self).__init__(123) |
---|
41 | n/a | |
---|
42 | n/a | class Meta(type): |
---|
43 | n/a | def __new__(meta, name, bases, namespace): |
---|
44 | n/a | return super().__new__(meta, name, bases, namespace) |
---|
45 | n/a | |
---|
46 | n/a | class S(metaclass = Meta): |
---|
47 | n/a | x: str = 'something' |
---|
48 | n/a | y: str = 'something else' |
---|
49 | n/a | |
---|
50 | n/a | def foo(x: int = 10): |
---|
51 | n/a | def bar(y: List[str]): |
---|
52 | n/a | x: str = 'yes' |
---|
53 | n/a | bar() |
---|