hardbyte / hardbyte/python-can

Increase the usage of augmented assignment statements

Abierto
#1,160 0 comentarios 1 reacción 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
1.6k
Forks
697
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.