11import logging
22from contextlib import AbstractContextManager
33from types import TracebackType
4- from typing import Generic , List , Optional , TypeVar
4+ from typing import Generic , TypeVar
55
66from nitrokey import nk3 , nkpk
77from nitrokey .nk3 import NK3
@@ -26,9 +26,9 @@ def __enter__(self) -> T:
2626
2727 def __exit__ (
2828 self ,
29- exc_type : Optional [ type [BaseException ]] ,
30- exc_val : Optional [ BaseException ] ,
31- exc_tb : Optional [ TracebackType ] ,
29+ exc_type : type [BaseException ] | None ,
30+ exc_val : BaseException | None ,
31+ exc_tb : TracebackType | None ,
3232 ) -> None :
3333 pass
3434
@@ -39,9 +39,9 @@ def __init__(self, device: TrussedBase, using_ccid: bool) -> None:
3939 self .model = device .model
4040 self .updating = False
4141
42- self ._status : Optional [ Status ] = None
43- self ._uuid : Optional [ Uuid ] = None
44- self ._version : Optional [ Version ] = None
42+ self ._status : Status | None = None
43+ self ._uuid : Uuid | None = None
44+ self ._version : Version | None = None
4545 self ._device = device
4646 self ._using_ccid = using_ccid
4747
@@ -58,7 +58,7 @@ def __repr__(self) -> str:
5858 return f"DeviceData({ fields_str } )"
5959
6060 @classmethod
61- def list (cls ) -> List ["DeviceData" ]:
61+ def list (cls ) -> list ["DeviceData" ]:
6262 use_ccid = should_use_ccid ()
6363
6464 nk3_devices = [cls (dev , use_ccid ) for dev in nk3 .list (use_ccid , exclusive = True )]
@@ -108,7 +108,7 @@ def version(self) -> Version:
108108 return self ._version
109109
110110 @property
111- def uuid (self ) -> Optional [ Uuid ] :
111+ def uuid (self ) -> Uuid | None :
112112 assert isinstance (self ._device , TrussedDevice )
113113 if not self ._uuid :
114114 self ._uuid = self ._device .uuid ()
@@ -124,7 +124,7 @@ def uuid_prefix(self) -> str:
124124 return str (self .uuid )[:5 ]
125125
126126 def open (self ) -> AbstractContextManager [TrussedDevice ]:
127- device : Optional [ TrussedDevice ] = None
127+ device : TrussedDevice | None = None
128128 if self .is_bootloader :
129129 raise RuntimeError ("Trying to open a device that is a bootloader" )
130130
@@ -148,7 +148,7 @@ def open(self) -> AbstractContextManager[TrussedDevice]:
148148 else :
149149 raise RuntimeError (f"Unknown device model { self ._device } " )
150150
151- def update (self , ui : UpdateGUI , image : Optional [ str ] = None ) -> UpdateResult :
151+ def update (self , ui : UpdateGUI , image : str | None = None ) -> UpdateResult :
152152 if self .path is None :
153153 return UpdateResult (
154154 self .model , UpdateStatus .ERROR , "Administrator rights are required for updating"
0 commit comments