• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __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()
55 
56 def dec(func):
57     @wraps(func)
58     def wrapper(*args, **kwargs):
59         return func(*args, **kwargs)
60     return wrapper
61