|
12 | 12 | http://construct.wikispaces.com (including online tutorial) |
13 | 13 |
|
14 | 14 | Typical usage: |
15 | | - >>> from construct import * |
| 15 | + >>> from ..construct import * |
16 | 16 |
|
17 | 17 | Hands-on example: |
18 | | - >>> from construct import * |
| 18 | + >>> from ..construct import * |
19 | 19 | >>> s = Struct("foo", |
20 | 20 | ... UBInt8("a"), |
21 | 21 | ... UBInt16("b"), |
22 | 22 | ... ) |
23 | | - >>> s.parse("\\x01\\x02\\x03") |
24 | | - Container(a = 1, b = 515) |
25 | | - >>> print(s.parse("\\x01\\x02\\x03")) |
26 | | - Container: |
27 | | - a = 1 |
28 | | - b = 515 |
29 | | - >>> s.build(Container(a = 1, b = 0x0203)) |
30 | | - "\\x01\\x02\\x03" |
| 23 | + >>> s.parse(b"\\x01\\x02\\x03") |
| 24 | + Container({'a': 1, 'b': 515}) |
| 25 | + >>> print(s.parse(b"\\x01\\x02\\x03")) |
| 26 | + Container({'a': 1, 'b': 515}) |
| 27 | + >>> s.build(Container(a=1, b=0x0203)) |
| 28 | + b'\\x01\\x02\\x03' |
31 | 29 | """ |
| 30 | +from __future__ import annotations |
32 | 31 |
|
| 32 | +from .lib.container import * |
33 | 33 | from .core import * |
34 | 34 | from .adapters import * |
35 | 35 | from .macros import * |
|
39 | 39 | #=============================================================================== |
40 | 40 | # Metadata |
41 | 41 | #=============================================================================== |
42 | | -__author__ = "tomer filiba (tomerfiliba [at] gmail.com)" |
43 | | -__maintainer__ = "Corbin Simpson <[email protected]>" |
44 | | -__version__ = "2.06" |
| 42 | +__author__: str = "tomer filiba (tomerfiliba [at] gmail.com)" |
| 43 | +__maintainer__: str = "Corbin Simpson <[email protected]>" |
| 44 | +__version__: str = "2.06" |
45 | 45 |
|
46 | 46 | #=============================================================================== |
47 | 47 | # Shorthand expressions |
|
59 | 59 | #=============================================================================== |
60 | 60 | import functools |
61 | 61 | import warnings |
| 62 | +from typing import TYPE_CHECKING, TypeVar |
62 | 63 |
|
63 | | -def deprecated(f): |
| 64 | +if TYPE_CHECKING: |
| 65 | + from collections.abc import Callable |
| 66 | + |
| 67 | + from typing_extensions import ParamSpec |
| 68 | + |
| 69 | + _P = ParamSpec('_P') |
| 70 | + _T = TypeVar('_T') |
| 71 | + |
| 72 | + |
| 73 | +def deprecated(f: Callable[_P, _T]) -> Callable[_P, _T]: |
64 | 74 | @functools.wraps(f) |
65 | | - def wrapper(*args, **kwargs): |
| 75 | + def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T: |
66 | 76 | warnings.warn( |
67 | 77 | "This name is deprecated, use %s instead" % f.__name__, |
68 | 78 | DeprecationWarning, stacklevel=2) |
|
0 commit comments