• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
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
9from functools import wraps
10
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()
55
56def dec(func):
57    @wraps(func)
58    def wrapper(*args, **kwargs):
59        return func(*args, **kwargs)
60    return wrapper
61
62u: int | float
63