What changed, and why it matters
This commit adds backward-compatibility shims so that older code referencing certain moved Python modules still works, but now shows a deprecation warning. There is no security issue here; it is a routine code-maintenance change.
No security action required. Users of the library should update imports before the deprecated aliases are removed in version 0.21.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit introduces module-level getattr hooks in trezorlib/tools.py and a new trezorlib/ui.py. When code imports trezorlib.tools.EnumAdapter/TupleAdapter or any name from trezorlib.ui, the hook emits a DeprecationWarning and redirects to the new locations (trezorlib.construct_helpers and trezorlib.cli.ui respectively). This is a pure compatibility/deprecation helper with no functional or security changes.
Changed components
python/src/trezorlib/tools.pypython/src/trezorlib/ui.pyInspect captured patch +35 / −0
diff --git a/python/.changelog.d/6564.deprecated b/python/.changelog.d/6564.deprecated
new file mode 100644
index 00000000..427dc4a2
--- /dev/null
+++ b/python/.changelog.d/6564.deprecated
@@ -0,0 +1 @@
+`trezorlib.ui` is deprecated, the module has been moved to `trezorlib.cli.ui`.
diff --git a/python/.changelog.d/6564.deprecated.1 b/python/.changelog.d/6564.deprecated.1
new file mode 100644
index 00000000..a81eaad3
--- /dev/null
+++ b/python/.changelog.d/6564.deprecated.1
@@ -0,0 +1 @@
+`trezorlib.tools.EnumAdapter` and `TupleAdaper` have been moved to `trezorlib.construct_helpers`.
diff --git a/python/src/trezorlib/tools.py b/python/src/trezorlib/tools.py
index c8c0940d..b882c5af 100644
--- a/python/src/trezorlib/tools.py
+++ b/python/src/trezorlib/tools.py
@@ -387,3 +387,23 @@ class workflow(t.Generic[P, R]):
session.refresh_features()
return result
+
+
+def __getattr__(name: str) -> t.Any:
+ import warnings
+
+ if name not in ("EnumAdapter", "TupleAdapter"):
+ raise AttributeError(f"module 'trezorlib.tools' has no attribute '{name}'")
+ warnings.warn(
+ f"trezorlib.tools.{name} is deprecated and will be removed in 0.21. Use trezorlib.construct_helpers.{name} instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+
+ from . import construct_helpers
+
+ if name == "EnumAdapter":
+ return construct_helpers.EnumAdapter
+ if name == "TupleAdapter":
+ return construct_helpers.TupleAdapter
+ raise AttributeError(f"module 'trezorlib.tools' has no attribute '{name}'")
diff --git a/python/src/trezorlib/ui.py b/python/src/trezorlib/ui.py
new file mode 100644
index 00000000..e3f0cdc6
--- /dev/null
+++ b/python/src/trezorlib/ui.py
@@ -0,0 +1,13 @@
+import warnings
+from typing import Any
+
+
+def __getattr__(name: str) -> Any:
+ from .cli import ui
+
+ warnings.warn(
+ "trezorlib.ui is deprecated and will be removed in 0.21. Use trezorlib.cli.ui instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return getattr(ui, name)
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.