diff --git a/python/.changelog.d/4464.deprecated.2 b/python/.changelog.d/4464.deprecated.2 new file mode 100644 index 0000000000..1843512b8b --- /dev/null +++ b/python/.changelog.d/4464.deprecated.2 @@ -0,0 +1 @@ +`@expect` decorator is deprecated -- use `TrezorClient.call(expect=...)` instead. diff --git a/python/src/trezorlib/tools.py b/python/src/trezorlib/tools.py index 18f62061cf..13a4d6d5cb 100644 --- a/python/src/trezorlib/tools.py +++ b/python/src/trezorlib/tools.py @@ -14,11 +14,14 @@ # You should have received a copy of the License along with this library. # If not, see . +from __future__ import annotations + import functools import hashlib import re import struct import unicodedata +import warnings from typing import ( TYPE_CHECKING, Any, @@ -279,10 +282,16 @@ def expect( ret_type: "Optional[Type[R]]" = None, ) -> "Callable[[Callable[P, MessageType]], Callable[P, Union[MT, R]]]": """ - Decorator checks if the method - returned one of expected protobuf messages - or raises an exception + Decorator checks if the method returned one of expected protobuf messages or raises + an exception. + + Deprecated. Use `client.call(msg, expect=expected)` instead. """ + warnings.warn( + "Use `client.call(msg, expect=expected)` instead", + DeprecationWarning, + stacklevel=2, + ) def decorator(f: "Callable[P, MessageType]") -> "Callable[P, Union[MT, R]]": @functools.wraps(f)