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