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