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