@@ -77,8 +77,8 @@ def __vciFormatErrorExtended(
7777 Formatted string
7878 """
7979 # TODO: make sure we don't generate another exception
80- return "{} - arguments were {}" . format (
81- __vciFormatError (library_instance , function , vret ), args
80+ return (
81+ f" { __vciFormatError (library_instance , function , vret )} - arguments were { args } "
8282 )
8383
8484
@@ -553,13 +553,11 @@ def __init__(
553553 if unique_hardware_id is None :
554554 raise VCIDeviceNotFoundError (
555555 "No IXXAT device(s) connected or device(s) in use by other process(es)."
556- )
556+ ) from None
557557 else :
558558 raise VCIDeviceNotFoundError (
559- "Unique HW ID {} not connected or not available." .format (
560- unique_hardware_id
561- )
562- )
559+ f"Unique HW ID { unique_hardware_id } not connected or not available."
560+ ) from None
563561 else :
564562 if (unique_hardware_id is None ) or (
565563 self ._device_info .UniqueHardwareId .AsChar
@@ -579,7 +577,9 @@ def __init__(
579577 ctypes .byref (self ._device_handle ),
580578 )
581579 except Exception as exception :
582- raise CanInitializationError (f"Could not open device: { exception } " )
580+ raise CanInitializationError (
581+ f"Could not open device: { exception } "
582+ ) from exception
583583
584584 log .info ("Using unique HW ID %s" , self ._device_info .UniqueHardwareId .AsChar )
585585
@@ -600,7 +600,7 @@ def __init__(
600600 except Exception as exception :
601601 raise CanInitializationError (
602602 f"Could not open and initialize channel: { exception } "
603- )
603+ ) from exception
604604
605605 # Signal TX/RX events when at least one frame has been handled
606606 _canlib .canChannelInitialize (
@@ -959,7 +959,8 @@ def _send_periodic_internal(
959959 # fallback to thread based cyclic task
960960 warnings .warn (
961961 f"{ self .__class__ .__name__ } falls back to a thread-based cyclic task, "
962- "when the `modifier_callback` argument is given."
962+ "when the `modifier_callback` argument is given." ,
963+ stacklevel = 3 ,
963964 )
964965 return BusABC ._send_periodic_internal (
965966 self ,
0 commit comments