hardbyte / hardbyte/python-can

Increase the usage of augmented assignment statements

オープン
#1,160 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
1.6k
フォーク
697
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。