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