diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-08-23 15:42:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 15:42:08 (GMT) |
commit | 3f61cf646d0506baa0c0c2118f05110446519c62 (patch) | |
tree | 0422bf72d76cdcdbb8387f761a429f2402b05baf /Lib/test/typinganndata/ann_module.py | |
parent | f5559f38d9831e7e55a518e516bcd620ec13af14 (diff) | |
download | cpython-3f61cf646d0506baa0c0c2118f05110446519c62.zip cpython-3f61cf646d0506baa0c0c2118f05110446519c62.tar.gz cpython-3f61cf646d0506baa0c0c2118f05110446519c62.tar.bz2 |
gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354)
Diffstat (limited to 'Lib/test/typinganndata/ann_module.py')
-rw-r--r-- | Lib/test/typinganndata/ann_module.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Lib/test/typinganndata/ann_module.py b/Lib/test/typinganndata/ann_module.py new file mode 100644 index 0000000..5081e6b --- /dev/null +++ b/Lib/test/typinganndata/ann_module.py @@ -0,0 +1,62 @@ + + +""" +The module for testing variable annotations. +Empty lines above are for good reason (testing for correct line numbers) +""" + +from typing import Optional +from functools import wraps + +__annotations__[1] = 2 + +class C: + + x = 5; y: Optional['C'] = None + +from typing import Tuple +x: int = 5; y: str = x; f: Tuple[int, int] + +class M(type): + + __annotations__['123'] = 123 + o: type = object + +(pars): bool = True + +class D(C): + j: str = 'hi'; k: str= 'bye' + +from types import new_class +h_class = new_class('H', (C,)) +j_class = new_class('J') + +class F(): + z: int = 5 + def __init__(self, x): + pass + +class Y(F): + def __init__(self): + super(F, self).__init__(123) + +class Meta(type): + def __new__(meta, name, bases, namespace): + return super().__new__(meta, name, bases, namespace) + +class S(metaclass = Meta): + x: str = 'something' + y: str = 'something else' + +def foo(x: int = 10): + def bar(y: List[str]): + x: str = 'yes' + bar() + +def dec(func): + @wraps(func) + def wrapper(*args, **kwargs): + return func(*args, **kwargs) + return wrapper + +u: int | float |