chore(core): simplify `interact()` type annotation
What changed, and why it matters
This is a minor code cleanup that simplifies a type annotation and removes a now-unnecessary runtime type check. It does not change security behavior or fix any vulnerability.
No security action needed. Treat as ordinary maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit narrows the accepted type of layout_obj in interact() from ui.LayoutObj[T] | ui.Layout[T] to just ui.LayoutObj[T], and removes the conditional branch that directly accepted ui.Layout instances. This is a refactoring enabled by prior changes that eliminated direct ui.Layout callers. There is no functional or security change.
Changed components
core/src/trezor/ui/layouts/common.pyInspect captured patch +2 / −4
diff --git a/core/src/trezor/ui/layouts/common.py b/core/src/trezor/ui/layouts/common.py
index bb98ce29..1e115be4 100644
--- a/core/src/trezor/ui/layouts/common.py
+++ b/core/src/trezor/ui/layouts/common.py
@@ -40,7 +40,7 @@ if TYPE_CHECKING:
async def interact(
- layout_obj: ui.LayoutObj[T] | ui.Layout[T],
+ layout_obj: ui.LayoutObj[T],
br_name: str | None,
br_code: ButtonRequestType = ButtonRequestType.Other,
raise_on_cancel: ExceptionType | None = ActionCancelled,
@@ -64,9 +64,7 @@ async def interact(
# shut down other workflows to prevent them from interfering with the current one
workflow.close_others()
# start the layout
- layout = (
- layout_obj if isinstance(layout_obj, ui.Layout) else layout_type(layout_obj)
- )
+ layout = layout_type(layout_obj)
layout.start()
if br_name is not None:
# store the first button request to be sent
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.