hardbyte / hardbyte/python-can

Increase the usage of augmented assignment statements

Đang mở
#1,160 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
1.6k
Fork
697
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

: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]
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.