mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
style(core): upgrade pyright to 1.1.361
[no changelog]
This commit is contained in:
parent
ec8da46fe5
commit
8640b50d81
@ -1877,7 +1877,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// title: str,
|
||||
/// button: str,
|
||||
/// info_button: str, # unused on TR
|
||||
/// items: Iterable[Tuple[int, str]],
|
||||
/// items: Iterable[Tuple[int, str | bytes]],
|
||||
/// verb_cancel: str | None = None,
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Confirm given items but with third button. Always single page
|
||||
@ -1888,7 +1888,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// *,
|
||||
/// title: str,
|
||||
/// button: str,
|
||||
/// items: Iterable[tuple[int, str]],
|
||||
/// items: Iterable[tuple[int, str | bytes]],
|
||||
/// ) -> object:
|
||||
/// """Confirm long content with the possibility to go back from any page.
|
||||
/// Meant to be used with confirm_with_info."""
|
||||
|
@ -1947,7 +1947,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// title: str,
|
||||
/// button: str,
|
||||
/// info_button: str,
|
||||
/// items: Iterable[tuple[int, str]],
|
||||
/// items: Iterable[tuple[int, str | bytes]],
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Confirm given items but with third button. Always single page
|
||||
/// without scrolling."""
|
||||
@ -1957,7 +1957,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// *,
|
||||
/// title: str,
|
||||
/// button: str,
|
||||
/// items: Iterable[tuple[int, str]],
|
||||
/// items: Iterable[tuple[int, str | bytes]],
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Confirm long content with the possibility to go back from any page.
|
||||
/// Meant to be used with confirm_with_info."""
|
||||
|
@ -257,7 +257,7 @@ def confirm_with_info(
|
||||
title: str,
|
||||
button: str,
|
||||
info_button: str, # unused on TR
|
||||
items: Iterable[Tuple[int, str]],
|
||||
items: Iterable[Tuple[int, str | bytes]],
|
||||
verb_cancel: str | None = None,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Confirm given items but with third button. Always single page
|
||||
@ -269,7 +269,7 @@ def confirm_more(
|
||||
*,
|
||||
title: str,
|
||||
button: str,
|
||||
items: Iterable[tuple[int, str]],
|
||||
items: Iterable[tuple[int, str | bytes]],
|
||||
) -> object:
|
||||
"""Confirm long content with the possibility to go back from any page.
|
||||
Meant to be used with confirm_with_info."""
|
||||
@ -768,7 +768,7 @@ def confirm_with_info(
|
||||
title: str,
|
||||
button: str,
|
||||
info_button: str,
|
||||
items: Iterable[tuple[int, str]],
|
||||
items: Iterable[tuple[int, str | bytes]],
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Confirm given items but with third button. Always single page
|
||||
without scrolling."""
|
||||
@ -779,7 +779,7 @@ def confirm_more(
|
||||
*,
|
||||
title: str,
|
||||
button: str,
|
||||
items: Iterable[tuple[int, str]],
|
||||
items: Iterable[tuple[int, str | bytes]],
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Confirm long content with the possibility to go back from any page.
|
||||
Meant to be used with confirm_with_info."""
|
||||
|
@ -418,7 +418,7 @@ def get_pinlocked_handler(
|
||||
if msg_type in workflow.ALLOW_WHILE_LOCKED:
|
||||
return orig_handler
|
||||
|
||||
async def wrapper(msg: wire.Msg) -> protobuf.MessageType:
|
||||
async def wrapper(msg: protobuf.MessageType) -> protobuf.MessageType:
|
||||
await unlock_device()
|
||||
return await orig_handler(msg)
|
||||
|
||||
@ -442,7 +442,7 @@ def boot() -> None:
|
||||
MT = MessageType # local_cache_global
|
||||
|
||||
# Register workflow handlers
|
||||
for msg_type, handler in (
|
||||
for msg_type, handler in [
|
||||
(MT.Initialize, handle_Initialize),
|
||||
(MT.GetFeatures, handle_GetFeatures),
|
||||
(MT.Cancel, handle_Cancel),
|
||||
@ -453,8 +453,8 @@ def boot() -> None:
|
||||
(MT.UnlockPath, handle_UnlockPath),
|
||||
(MT.CancelAuthorization, handle_CancelAuthorization),
|
||||
(MT.SetBusy, handle_SetBusy),
|
||||
):
|
||||
workflow_handlers.register(msg_type, handler) # type: ignore [cannot be assigned to type]
|
||||
]:
|
||||
workflow_handlers.register(msg_type, handler)
|
||||
|
||||
reload_settings_from_storage()
|
||||
if config.is_unlocked():
|
||||
|
@ -46,7 +46,8 @@ class SigHashType(IntEnum):
|
||||
|
||||
@classmethod
|
||||
def from_int(cls, sighash_type: int) -> "SigHashType":
|
||||
for val in cls.__dict__.values(): # type: SigHashType
|
||||
val: SigHashType
|
||||
for val in cls.__dict__.values():
|
||||
if val == sighash_type:
|
||||
return val
|
||||
raise ValueError("Unsupported sighash type.")
|
||||
|
@ -316,7 +316,7 @@ def _get_unlock_schemas(
|
||||
|
||||
def with_keychain(func: HandlerWithCoinInfo[MsgOut]) -> Handler[MsgIn, MsgOut]:
|
||||
async def wrapper(
|
||||
msg: MsgIn,
|
||||
msg: BitcoinMessage,
|
||||
auth_msg: MessageType | None = None,
|
||||
) -> MsgOut:
|
||||
coin = _get_coin_by_name(msg.coin_name)
|
||||
|
@ -241,80 +241,80 @@ class UiConfirmMultipleAccounts(UiConfirm):
|
||||
return layout.confirm_multiple_accounts()
|
||||
|
||||
|
||||
def confirm_output(output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit, output_index: int, chunkify: bool) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmOutput(output, coin, amount_unit, output_index, chunkify))
|
||||
def confirm_output(output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit, output_index: int, chunkify: bool) -> Awaitable[None]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmOutput(output, coin, amount_unit, output_index, chunkify)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_decred_sstx_submission(output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmDecredSSTXSubmission(output, coin, amount_unit))
|
||||
def confirm_decred_sstx_submission(output: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[None]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmDecredSSTXSubmission(output, coin, amount_unit)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def should_show_payment_request_details(payment_req: TxAckPaymentRequest, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[bool]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmPaymentRequest(payment_req, coin, amount_unit))
|
||||
def should_show_payment_request_details(payment_req: TxAckPaymentRequest, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[bool]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmPaymentRequest(payment_req, coin, amount_unit)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_replacement(description: str, txid: bytes) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmReplacement(description, txid))
|
||||
def confirm_replacement(description: str, txid: bytes) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmReplacement(description, txid)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_modify_output(txo: TxOutput, orig_txo: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmModifyOutput(txo, orig_txo, coin, amount_unit))
|
||||
def confirm_modify_output(txo: TxOutput, orig_txo: TxOutput, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmModifyOutput(txo, orig_txo, coin, amount_unit)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_modify_fee(title: str, user_fee_change: int, total_fee_new: int, fee_rate: float, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
def confirm_modify_fee(title: str, user_fee_change: int, total_fee_new: int, fee_rate: float, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (
|
||||
yield UiConfirmModifyFee(
|
||||
yield UiConfirmModifyFee( # type: ignore [awaitable-return-type]
|
||||
title, user_fee_change, total_fee_new, fee_rate, coin, amount_unit
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def confirm_total(spending: int, fee: int, fee_rate: float, coin: CoinInfo, amount_unit: AmountUnit, address_n: Bip32Path | None) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmTotal(spending, fee, fee_rate, coin, amount_unit, address_n))
|
||||
def confirm_total(spending: int, fee: int, fee_rate: float, coin: CoinInfo, amount_unit: AmountUnit, address_n: Bip32Path | None) -> Awaitable[None]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmTotal(spending, fee, fee_rate, coin, amount_unit, address_n)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_joint_total(spending: int, total: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmJointTotal(spending, total, coin, amount_unit))
|
||||
def confirm_joint_total(spending: int, total: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmJointTotal(spending, total, coin, amount_unit)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_feeoverthreshold(fee: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmFeeOverThreshold(fee, coin, amount_unit))
|
||||
def confirm_feeoverthreshold(fee: int, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmFeeOverThreshold(fee, coin, amount_unit)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_change_count_over_threshold(change_count: int) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmChangeCountOverThreshold(change_count))
|
||||
def confirm_change_count_over_threshold(change_count: int) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmChangeCountOverThreshold(change_count)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_unverified_external_input() -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmUnverifiedExternalInput())
|
||||
def confirm_unverified_external_input() -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmUnverifiedExternalInput()) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_foreign_address(address_n: list) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmForeignAddress(address_n))
|
||||
def confirm_foreign_address(address_n: list) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmForeignAddress(address_n)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_nondefault_locktime(lock_time: int, lock_time_disabled: bool) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmNonDefaultLocktime(lock_time, lock_time_disabled))
|
||||
def confirm_nondefault_locktime(lock_time: int, lock_time_disabled: bool) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmNonDefaultLocktime(lock_time, lock_time_disabled)) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def confirm_multiple_accounts() -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
return (yield UiConfirmMultipleAccounts())
|
||||
def confirm_multiple_accounts() -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
return (yield UiConfirmMultipleAccounts()) # type: ignore [awaitable-return-type]
|
||||
|
||||
|
||||
def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevTx]: # type: ignore [awaitable-is-generator]
|
||||
def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevTx]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckPrevMeta
|
||||
|
||||
assert tx_req.details is not None
|
||||
tx_req.request_type = RequestType.TXMETA
|
||||
tx_req.details.tx_hash = tx_hash
|
||||
ack = yield TxAckPrevMeta, tx_req
|
||||
ack = yield TxAckPrevMeta, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
return _sanitize_tx_meta(ack.tx, coin)
|
||||
|
||||
|
||||
def request_tx_extra_data(
|
||||
tx_req: TxRequest, offset: int, size: int, tx_hash: bytes | None = None
|
||||
) -> Awaitable[bytearray]: # type: ignore [awaitable-is-generator]
|
||||
) -> Awaitable[bytearray]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckPrevExtraData
|
||||
|
||||
details = tx_req.details # local_cache_attribute
|
||||
@ -324,12 +324,12 @@ def request_tx_extra_data(
|
||||
details.extra_data_offset = offset
|
||||
details.extra_data_len = size
|
||||
details.tx_hash = tx_hash
|
||||
ack = yield TxAckPrevExtraData, tx_req
|
||||
ack = yield TxAckPrevExtraData, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
return ack.tx.extra_data_chunk
|
||||
|
||||
|
||||
def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[TxInput]: # type: ignore [awaitable-is-generator]
|
||||
def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[TxInput]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckInput
|
||||
|
||||
assert tx_req.details is not None
|
||||
@ -339,24 +339,24 @@ def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes |
|
||||
else:
|
||||
tx_req.request_type = RequestType.TXINPUT
|
||||
tx_req.details.request_index = i
|
||||
ack = yield TxAckInput, tx_req
|
||||
ack = yield TxAckInput, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
return _sanitize_tx_input(ack.tx.input, coin)
|
||||
|
||||
|
||||
def request_tx_prev_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevInput]: # type: ignore [awaitable-is-generator]
|
||||
def request_tx_prev_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevInput]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckPrevInput
|
||||
|
||||
assert tx_req.details is not None
|
||||
tx_req.request_type = RequestType.TXINPUT
|
||||
tx_req.details.request_index = i
|
||||
tx_req.details.tx_hash = tx_hash
|
||||
ack = yield TxAckPrevInput, tx_req
|
||||
ack = yield TxAckPrevInput, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
return _sanitize_tx_prev_input(ack.tx.input, coin)
|
||||
|
||||
|
||||
def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[TxOutput]: # type: ignore [awaitable-is-generator]
|
||||
def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[TxOutput]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckOutput
|
||||
|
||||
assert tx_req.details is not None
|
||||
@ -366,38 +366,38 @@ def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes
|
||||
else:
|
||||
tx_req.request_type = RequestType.TXOUTPUT
|
||||
tx_req.details.request_index = i
|
||||
ack = yield TxAckOutput, tx_req
|
||||
ack = yield TxAckOutput, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
return _sanitize_tx_output(ack.tx.output, coin)
|
||||
|
||||
|
||||
def request_tx_prev_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevOutput]: # type: ignore [awaitable-is-generator]
|
||||
def request_tx_prev_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes | None = None) -> Awaitable[PrevOutput]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckPrevOutput
|
||||
|
||||
assert tx_req.details is not None
|
||||
tx_req.request_type = RequestType.TXOUTPUT
|
||||
tx_req.details.request_index = i
|
||||
tx_req.details.tx_hash = tx_hash
|
||||
ack = yield TxAckPrevOutput, tx_req
|
||||
ack = yield TxAckPrevOutput, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
# return sanitize_tx_prev_output(ack.tx, coin) # no sanitize is required
|
||||
return ack.tx.output
|
||||
|
||||
|
||||
def request_payment_req(tx_req: TxRequest, i: int) -> Awaitable[TxAckPaymentRequest]: # type: ignore [awaitable-is-generator]
|
||||
def request_payment_req(tx_req: TxRequest, i: int) -> Awaitable[TxAckPaymentRequest]: # type: ignore [awaitable-return-type]
|
||||
from trezor.messages import TxAckPaymentRequest
|
||||
|
||||
assert tx_req.details is not None
|
||||
tx_req.request_type = RequestType.TXPAYMENTREQ
|
||||
tx_req.details.request_index = i
|
||||
ack = yield TxAckPaymentRequest, tx_req
|
||||
ack = yield TxAckPaymentRequest, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
return _sanitize_payment_req(ack)
|
||||
|
||||
|
||||
def request_tx_finish(tx_req: TxRequest) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
def request_tx_finish(tx_req: TxRequest) -> Awaitable[None]: # type: ignore [awaitable-return-type]
|
||||
tx_req.request_type = RequestType.TXFINISHED
|
||||
yield None, tx_req
|
||||
yield None, tx_req # type: ignore [awaitable-return-type]
|
||||
_clear_tx_request(tx_req)
|
||||
|
||||
|
||||
|
@ -129,7 +129,7 @@ def _validate_address_parameters_structure(
|
||||
script_staking_hash = parameters.script_staking_hash # local_cache_attribute
|
||||
CAT = CardanoAddressType # local_cache_global
|
||||
|
||||
fields_to_be_empty: dict[CAT, tuple[Any, ...]] = {
|
||||
fields_to_be_empty: dict[CardanoAddressType, tuple[Any, ...]] = {
|
||||
CAT.BASE: (
|
||||
certificate_pointer,
|
||||
script_payment_hash,
|
||||
|
@ -70,7 +70,7 @@ def _validate_structure(certificate: messages.CardanoTxCertificate) -> None:
|
||||
pool_parameters = certificate.pool_parameters # local_cache_attribute
|
||||
CCT = CardanoCertificateType # local_cache_global
|
||||
|
||||
fields_to_be_empty: dict[CCT, tuple[Any, ...]] = {
|
||||
fields_to_be_empty: dict[CardanoCertificateType, tuple[Any, ...]] = {
|
||||
CCT.STAKE_REGISTRATION: (pool, pool_parameters),
|
||||
CCT.STAKE_DELEGATION: (pool_parameters,),
|
||||
CCT.STAKE_DEREGISTRATION: (pool, pool_parameters),
|
||||
|
@ -23,7 +23,7 @@ class HashBuilderCollection:
|
||||
self.size = size
|
||||
self.remaining = size
|
||||
self.hash_fn: HashContext | None = None
|
||||
self.parent: "HashBuilderCollection" | None = None
|
||||
self.parent: "HashBuilderCollection | None" = None
|
||||
self.has_unfinished_child = False
|
||||
|
||||
def start(self, hash_fn: HashContext) -> "HashBuilderCollection":
|
||||
|
@ -73,7 +73,7 @@ def _validate_native_script_structure(script: messages.CardanoNativeScript) -> N
|
||||
invalid_hereafter = script.invalid_hereafter # local_cache_attribute
|
||||
CNST = CardanoNativeScriptType # local_cache_global
|
||||
|
||||
fields_to_be_empty: dict[CNST, tuple[Any, ...]] = {
|
||||
fields_to_be_empty: dict[CardanoNativeScriptType, tuple[Any, ...]] = {
|
||||
CNST.PUB_KEY: (
|
||||
scripts,
|
||||
required_signatures_count,
|
||||
|
@ -9,7 +9,7 @@ if TYPE_CHECKING:
|
||||
|
||||
from typing_extensions import Protocol
|
||||
|
||||
Bip32Path = Sequence[int]
|
||||
Bip32Path = list[int]
|
||||
Slip21Path = Sequence[bytes]
|
||||
PathType = TypeVar("PathType", Bip32Path, Slip21Path, contravariant=True)
|
||||
|
||||
@ -290,7 +290,7 @@ class PathSchema:
|
||||
# Which in practice it is, the only non-Collection is Interval.
|
||||
# But we're not going to introduce an additional type requirement
|
||||
# for the sake of __repr__ that doesn't exist in production anyway
|
||||
collection: Collection[int] = component # type: ignore [Expression of type "Container[int]" cannot be assigned to declared type "Collection[int]"]
|
||||
collection: Collection[int] = component # type: ignore [Expression of type "Container[int]" is incompatible with declared type "Collection[int]"]
|
||||
component_str = ",".join(str(unharden(i)) for i in collection)
|
||||
if len(collection) > 1:
|
||||
component_str = "[" + component_str + "]"
|
||||
|
@ -118,7 +118,7 @@ async def verify_user_pin(
|
||||
raise RuntimeError
|
||||
|
||||
while retry:
|
||||
pin = await request_pin_on_device( # type: ignore ["request_pin_on_device" is possibly unbound]
|
||||
pin = await request_pin_on_device(
|
||||
TR.pin__enter, config.get_pin_rem(), allow_cancel, wrong_pin=True
|
||||
)
|
||||
if config.unlock(pin, salt):
|
||||
|
@ -129,7 +129,7 @@ if __debug__:
|
||||
async def return_layout_change() -> None:
|
||||
content_tokens = await get_layout_change_content()
|
||||
|
||||
assert DEBUG_CONTEXT is not None
|
||||
assert isinstance(DEBUG_CONTEXT, context.Context)
|
||||
if storage.layout_watcher is LAYOUT_WATCHER_LAYOUT:
|
||||
await DEBUG_CONTEXT.write(DebugLinkLayout(tokens=content_tokens))
|
||||
else:
|
||||
|
@ -169,7 +169,7 @@ class Transaction:
|
||||
def _create_instructions(self) -> None:
|
||||
# Instructions reference accounts by index in this combined list.
|
||||
combined_accounts = (
|
||||
self.addresses # type: ignore [Operator "+" not supported for types "list[Address]" and "list[AddressReference]"]
|
||||
self.addresses
|
||||
+ self.address_lookup_tables_rw_addresses
|
||||
+ self.address_lookup_tables_ro_addresses
|
||||
)
|
||||
|
@ -132,7 +132,7 @@ def get_backup_type() -> BackupType:
|
||||
):
|
||||
# Invalid backup type
|
||||
raise RuntimeError
|
||||
return backup_type # type: ignore [int-into-enum]
|
||||
return backup_type
|
||||
|
||||
|
||||
def is_passphrase_enabled() -> bool:
|
||||
@ -304,7 +304,7 @@ def safety_check_level() -> StorageSafetyCheckLevel:
|
||||
if level not in (SAFETY_CHECK_LEVEL_STRICT, SAFETY_CHECK_LEVEL_PROMPT):
|
||||
return _DEFAULT_SAFETY_CHECK_LEVEL
|
||||
else:
|
||||
return level # type: ignore [int-into-enum]
|
||||
return level
|
||||
|
||||
|
||||
# do not use this function directly, see apps.common.safety_checks instead
|
||||
|
@ -60,11 +60,11 @@ def exception(name: str, exc: BaseException) -> None:
|
||||
name,
|
||||
_DEBUG,
|
||||
"ui.Result: %s",
|
||||
exc.value, # type: ignore[Cannot access member "value" for type "BaseException"]
|
||||
exc.value, # type: ignore[Cannot access attribute "value" for class "BaseException"]
|
||||
)
|
||||
elif exc.__class__.__name__ == "Cancelled":
|
||||
_log(name, _DEBUG, "ui.Cancelled")
|
||||
else:
|
||||
_log(name, _ERROR, "exception:")
|
||||
# since mypy 0.770 we cannot override sys, so print_exception is unknown
|
||||
sys.print_exception(exc) # type: ignore ["print_exception" is not a known member of module]
|
||||
sys.print_exception(exc) # type: ignore ["print_exception" is not a known attribute of module]
|
||||
|
@ -295,7 +295,7 @@ class race(Syscall):
|
||||
# child is a layout -- type-wise, it is an Awaitable, but
|
||||
# implementation-wise it is an Iterable and we know that its __iter__
|
||||
# will return a Generator.
|
||||
child_task = child.__iter__() # type: ignore [Cannot access member "__iter__" for type "Awaitable[Unknown]";;Cannot access member "__iter__" for type "Coroutine[Unknown, Unknown, Unknown]"]
|
||||
child_task = child.__iter__() # type: ignore [Cannot access attribute "__iter__" for class "Awaitable[Unknown]";;Cannot access attribute "__iter__" for class "Coroutine[Unknown, Unknown, Unknown]"]
|
||||
schedule(child_task, None, None, finalizer)
|
||||
scheduled.append(child_task)
|
||||
|
||||
@ -319,7 +319,7 @@ class race(Syscall):
|
||||
self.exit(task)
|
||||
schedule(self.callback, result)
|
||||
|
||||
def __iter__(self) -> Task: # type: ignore [awaitable-is-generator]
|
||||
def __iter__(self) -> Task:
|
||||
try:
|
||||
return (yield self)
|
||||
except: # noqa: E722
|
||||
@ -383,20 +383,20 @@ class chan:
|
||||
self.putters: list[tuple[Task | None, Any]] = []
|
||||
self.takers: list[Task] = []
|
||||
|
||||
def put(self, value: Any) -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
def put(self, value: Any) -> Awaitable[None]: # type: ignore [awaitable-return-type]
|
||||
put = chan.Put(self, value)
|
||||
try:
|
||||
return (yield put)
|
||||
return (yield put) # type: ignore [awaitable-return-type]
|
||||
except: # noqa: E722
|
||||
entry = (put.task, value)
|
||||
if entry in self.putters:
|
||||
self.putters.remove(entry)
|
||||
raise
|
||||
|
||||
def take(self) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
|
||||
def take(self) -> Awaitable[Any]: # type: ignore [awaitable-return-type]
|
||||
take = chan.Take(self)
|
||||
try:
|
||||
return (yield take)
|
||||
return (yield take) # type: ignore [awaitable-return-type]
|
||||
except: # noqa: E722
|
||||
if take.task in self.takers:
|
||||
self.takers.remove(take.task)
|
||||
@ -493,7 +493,7 @@ class spawn(Syscall):
|
||||
if self.finalizer_callback is not None:
|
||||
self.finalizer_callback(self)
|
||||
|
||||
def __iter__(self) -> Task: # type: ignore [awaitable-is-generator]
|
||||
def __iter__(self) -> Task:
|
||||
if self.finished:
|
||||
# exit immediately if we already have a return value
|
||||
if isinstance(self.return_value, BaseException):
|
||||
|
@ -2,8 +2,8 @@ try:
|
||||
from trezorio import fatfs, sdcard
|
||||
|
||||
HAVE_SDCARD = True
|
||||
is_present = sdcard.is_present # type: ignore [obscured-by-same-name]
|
||||
capacity = sdcard.capacity # type: ignore [obscured-by-same-name]
|
||||
is_present = sdcard.is_present
|
||||
capacity = sdcard.capacity
|
||||
|
||||
except Exception:
|
||||
HAVE_SDCARD = False
|
||||
@ -27,7 +27,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class FilesystemWrapper:
|
||||
_INSTANCE: "FilesystemWrapper" | None = None
|
||||
_INSTANCE: "FilesystemWrapper | None" = None
|
||||
|
||||
def __init__(self, mounted: bool) -> None:
|
||||
if not HAVE_SDCARD:
|
||||
|
@ -45,7 +45,7 @@ if __debug__:
|
||||
display.refresh()
|
||||
|
||||
else:
|
||||
refresh = display.refresh # type: ignore [obscured-by-same-name]
|
||||
refresh = display.refresh
|
||||
|
||||
|
||||
# in both debug and production, emulator needs to draw the screen explicitly
|
||||
@ -188,6 +188,6 @@ class Layout(Generic[T]):
|
||||
content_store.append(self.__class__.__name__)
|
||||
|
||||
|
||||
def wait_until_layout_is_running() -> Awaitable[None]: # type: ignore [awaitable-is-generator]
|
||||
def wait_until_layout_is_running() -> Awaitable[None]: # type: ignore [awaitable-return-type]
|
||||
while not layout_chan.takers:
|
||||
yield
|
||||
yield # type: ignore [awaitable-return-type]
|
||||
|
@ -35,8 +35,8 @@ async def interact(
|
||||
br_code: ButtonRequestType = ButtonRequestType.Other,
|
||||
) -> T:
|
||||
pages = None
|
||||
if hasattr(layout, "page_count") and layout.page_count() > 1: # type: ignore [Cannot access member "page_count" for type "LayoutType"]
|
||||
if hasattr(layout, "page_count") and layout.page_count() > 1: # type: ignore [Cannot access attribute "page_count" for class "LayoutType"]
|
||||
# We know for certain how many pages the layout will have
|
||||
pages = layout.page_count() # type: ignore [Cannot access member "page_count" for type "LayoutType"]
|
||||
pages = layout.page_count() # type: ignore [Cannot access attribute "page_count" for class "LayoutType"]
|
||||
await button_request(br_type, br_code, pages)
|
||||
return await context.wait(layout)
|
||||
|
@ -221,7 +221,7 @@ class RustLayout(LayoutParentType[T]):
|
||||
|
||||
notify_layout_change(self, event_id)
|
||||
|
||||
def handle_input_and_rendering(self) -> loop.Task: # type: ignore [awaitable-is-generator]
|
||||
def handle_input_and_rendering(self) -> loop.Task:
|
||||
from trezor import workflow
|
||||
|
||||
button = loop.wait(io.BUTTON)
|
||||
@ -237,7 +237,7 @@ class RustLayout(LayoutParentType[T]):
|
||||
raise ui.Result(msg)
|
||||
self._paint()
|
||||
|
||||
def handle_timers(self) -> loop.Task: # type: ignore [awaitable-is-generator]
|
||||
def handle_timers(self) -> loop.Task:
|
||||
while True:
|
||||
# Using `yield` instead of `await` to avoid allocations.
|
||||
token = yield self.timer
|
||||
@ -849,7 +849,7 @@ async def _confirm_ask_pagination(
|
||||
) -> None:
|
||||
paginated: RustLayout[trezorui2.UiResult] | None = None
|
||||
# TODO: make should_show_more/confirm_more accept bytes directly
|
||||
if isinstance(data, bytes):
|
||||
if isinstance(data, (bytes, bytearray, memoryview)):
|
||||
from ubinascii import hexlify
|
||||
|
||||
data = hexlify(data).decode()
|
||||
@ -939,13 +939,14 @@ def confirm_properties(
|
||||
from ubinascii import hexlify
|
||||
|
||||
def handle_bytes(prop: PropertyType):
|
||||
if isinstance(prop[1], bytes):
|
||||
return (prop[0], hexlify(prop[1]).decode(), True)
|
||||
key, value = prop
|
||||
if isinstance(value, (bytes, bytearray, memoryview)):
|
||||
return (key, hexlify(value).decode(), True)
|
||||
else:
|
||||
# When there is not space in the text, taking it as data
|
||||
# to not include hyphens
|
||||
is_data = prop[1] and " " not in prop[1]
|
||||
return (prop[0], prop[1], is_data)
|
||||
is_data = value and " " not in value
|
||||
return (key, value, is_data)
|
||||
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
@ -1407,7 +1408,7 @@ def show_error_popup(
|
||||
time_ms=timeout_ms,
|
||||
)
|
||||
)
|
||||
return layout # type: ignore [Expression of type "RustLayout[UiResult]" cannot be assigned to return type "Awaitable[None]"]
|
||||
return layout # type: ignore [Expression of type "RustLayout[UiResult]" is incompatible with return type "Awaitable[None]"]
|
||||
|
||||
|
||||
def request_passphrase_on_host() -> None:
|
||||
|
@ -193,7 +193,7 @@ class RustLayout(LayoutParentType[T]):
|
||||
# Turn the brightness on again.
|
||||
ui.backlight_fade(self.BACKLIGHT_LEVEL)
|
||||
|
||||
def handle_input_and_rendering(self) -> loop.Task: # type: ignore [awaitable-is-generator]
|
||||
def handle_input_and_rendering(self) -> loop.Task:
|
||||
from trezor import workflow
|
||||
|
||||
touch = loop.wait(io.TOUCH)
|
||||
@ -209,7 +209,7 @@ class RustLayout(LayoutParentType[T]):
|
||||
raise ui.Result(msg)
|
||||
self._paint()
|
||||
|
||||
def handle_timers(self) -> loop.Task: # type: ignore [awaitable-is-generator]
|
||||
def handle_timers(self) -> loop.Task:
|
||||
while True:
|
||||
# Using `yield` instead of `await` to avoid allocations.
|
||||
token = yield self.timer
|
||||
@ -691,7 +691,7 @@ async def should_show_payment_request_details(
|
||||
|
||||
async def should_show_more(
|
||||
title: str,
|
||||
para: Iterable[tuple[int, str]],
|
||||
para: Iterable[tuple[int, str | bytes]],
|
||||
button_text: str | None = None,
|
||||
br_type: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
@ -1397,7 +1397,7 @@ def show_error_popup(
|
||||
allow_cancel=False,
|
||||
)
|
||||
)
|
||||
return layout # type: ignore [Expression of type "RustLayout[UiResult]" cannot be assigned to return type "Awaitable[None]"]
|
||||
return layout # type: ignore [Expression of type "RustLayout[UiResult]" is incompatible with return type "Awaitable[None]"]
|
||||
|
||||
|
||||
def request_passphrase_on_host() -> None:
|
||||
|
@ -302,14 +302,14 @@ class BufferReader:
|
||||
return byte
|
||||
|
||||
|
||||
def obj_eq(self: Any, __o: Any) -> bool:
|
||||
def obj_eq(__self: Any, __o: Any) -> bool:
|
||||
"""
|
||||
Compares object contents.
|
||||
"""
|
||||
if self.__class__ is not __o.__class__:
|
||||
if __self.__class__ is not __o.__class__:
|
||||
return False
|
||||
assert not hasattr(self, "__slots__")
|
||||
return self.__dict__ == __o.__dict__
|
||||
assert not hasattr(__self, "__slots__")
|
||||
return __self.__dict__ == __o.__dict__
|
||||
|
||||
|
||||
def obj_repr(self: Any) -> str:
|
||||
|
@ -141,9 +141,9 @@ FILE_SPECIFIC_IGNORES: FileSpecificIgnores = {}
|
||||
|
||||
# Allowing for more readable ignore of common problems, with an easy-to-understand alias
|
||||
ALIASES: dict[str, str] = {
|
||||
"awaitable-is-generator": 'Return type of generator function must be "Generator" or "Iterable"',
|
||||
"awaitable-return-type": 'Return type of generator function must be compatible with "Generator',
|
||||
"obscured-by-same-name": "is obscured by a declaration of the same name",
|
||||
"int-into-enum": 'Expression of type "int.*" cannot be assigned to return type ".*"',
|
||||
"int-into-enum": 'Expression of type "int.*" is incompatible with return type ".*"',
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user