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 |
benedwards14 | 0aca3a3 | 2019-11-21 17:24:58 +0000 | [diff] [blame] | 9 | from functools import wraps |
Yury Selivanov | f8cb8a1 | 2016-09-08 20:50:03 -0700 | [diff] [blame] | 10 | |
| 11 | __annotations__[1] = 2 |
| 12 | |
| 13 | class C: |
| 14 | |
| 15 | x = 5; y: Optional['C'] = None |
| 16 | |
| 17 | from typing import Tuple |
| 18 | x: int = 5; y: str = x; f: Tuple[int, int] |
| 19 | |
| 20 | class M(type): |
| 21 | |
| 22 | __annotations__['123'] = 123 |
| 23 | o: type = object |
| 24 | |
| 25 | (pars): bool = True |
| 26 | |
| 27 | class D(C): |
| 28 | j: str = 'hi'; k: str= 'bye' |
| 29 | |
| 30 | from types import new_class |
| 31 | h_class = new_class('H', (C,)) |
| 32 | j_class = new_class('J') |
| 33 | |
| 34 | class F(): |
| 35 | z: int = 5 |
| 36 | def __init__(self, x): |
| 37 | pass |
| 38 | |
| 39 | class Y(F): |
| 40 | def __init__(self): |
| 41 | super(F, self).__init__(123) |
| 42 | |
| 43 | class Meta(type): |
| 44 | def __new__(meta, name, bases, namespace): |
| 45 | return super().__new__(meta, name, bases, namespace) |
| 46 | |
| 47 | class S(metaclass = Meta): |
| 48 | x: str = 'something' |
| 49 | y: str = 'something else' |
| 50 | |
| 51 | def foo(x: int = 10): |
| 52 | def bar(y: List[str]): |
| 53 | x: str = 'yes' |
| 54 | bar() |
benedwards14 | 0aca3a3 | 2019-11-21 17:24:58 +0000 | [diff] [blame] | 55 | |
| 56 | def dec(func): |
| 57 | @wraps(func) |
| 58 | def wrapper(*args, **kwargs): |
| 59 | return func(*args, **kwargs) |
| 60 | return wrapper |
Ken Jin | a272164 | 2021-07-19 22:22:59 +0800 | [diff] [blame] | 61 | |
| 62 | u: int | float |