hardbyte / hardbyte/python-can

Increase the usage of augmented assignment statements

Open
#1,160 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
1.6k
Forks
697
PR merge metrics
No merged PRs in 30d

Description

:eyes: Some source code analysis tools can help to find opportunities for improving software components.
:thought_balloon: I propose to [increase the usage of augmented assignment statements](https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements "Augmented assignment statements") accordingly.

```diff
diff --git a/can/interfaces/gs_usb.py b/can/interfaces/gs_usb.py
index 447cdf4..3c619d6 100644
--- a/can/interfaces/gs_usb.py
+++ b/can/interfaces/gs_usb.py
@@ -44,13 +44,13 @@ class GsUsbBus(can.BusABC):
can_id = msg.arbitration_id

if msg.is_extended_id:
- can_id = can_id | CAN_EFF_FLAG
+ can_id |= CAN_EFF_FLAG

if msg.is_remote_frame:
- can_id = can_id | CAN_RTR_FLAG
+ can_id |= CAN_RTR_FLAG

if msg.is_error_frame:
- can_id = can_id | CAN_ERR_FLAG
+ can_id |= CAN_ERR_FLAG

# Pad message data
msg.data.extend([0x00] * (CAN_MAX_DLC - len(msg.data)))
diff --git a/can/interfaces/usb2can/serial_selector.py b/can/interfaces/usb2can/serial_selector.py
index fcc9512..a4e96b9 100644
--- a/can/interfaces/usb2can/serial_selector.py
+++ b/can/interfaces/usb2can/serial_selector.py
@@ -18,9 +18,9 @@ def WMIDateStringToDate(dtmDate) -> str:
strDateTime = dtmDate[4] + dtmDate[5] + "/"

if dtmDate[6] == 0:
- strDateTime = strDateTime + dtmDate[7] + "/"
+ strDateTime += dtmDate[7] + "/"
else:
- strDateTime = strDateTime + dtmDate[6] + dtmDate[7] + "/"
+ strDateTime += dtmDate[6] + dtmDate[7] + "/"
strDateTime = (
strDateTime
+ dtmDate[0]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.