chore(core): use `T | None` instead of `Optional[T]`
What changed, and why it matters
This is a minor code cleanup that changes how optional types are written in one Python file. It replaces the older `Optional[Type]` style with the newer `Type | None` style. There is no functional change and no security relevance.
No action needed. This is a non-functional style-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies type annotations only under a TYPE_CHECKING guard in core/src/trezor/wire/__init__.py. It removes the Optional import from typing and rewrites three parameter annotations (exc_type, exc, tb) from Optional[T] to T | None. These annotations are not evaluated at runtime and do not alter program behavior.
Changed components
core/src/trezor/wire/__init__.pyInspect captured patch +4 / −4
diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py
index 286a72183..3a330f54d 100644
--- a/core/src/trezor/wire/__init__.py
+++ b/core/src/trezor/wire/__init__.py
@@ -50,7 +50,7 @@ if TYPE_CHECKING:
from buffer_types import AnyBytes
from trezorio import WireInterface
from types import TracebackType
- from typing import Any, Callable, Coroutine, Generic, Optional, Type, TypeVar
+ from typing import Any, Callable, Coroutine, Generic, Type, TypeVar
from trezor.wire.thp.channel import Channel
@@ -75,9 +75,9 @@ class _HighSpeed:
def __exit__(
self,
- exc_type: Optional[Type[BaseException]],
- exc: Optional[BaseException],
- tb: Optional[TracebackType],
+ exc_type: Type[BaseException] | None,
+ exc: BaseException | None,
+ tb: TracebackType | None,
) -> bool:
if utils.USE_BLE:
from trezorble import set_high_speed
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.