1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-29 16:51:30 +00:00

deprecation(python): deprecate @expect

This commit is contained in:
matejcik 2025-01-03 12:28:54 +01:00 committed by matejcik
parent 8b6d8e7572
commit 0cae2ab2d0
2 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1 @@
`@expect` decorator is deprecated -- use `TrezorClient.call(expect=...)` instead.

View File

@ -14,11 +14,14 @@
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
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)