mirror of https://github.com/commaai/panda.git
Ruff: propgate config from OP (#1579)
This commit is contained in:
parent
05295dc42a
commit
4ea50fbb09
|
@ -17,7 +17,7 @@ if __name__ == "__main__":
|
|||
if os.getenv("SERIAL"):
|
||||
serials = [x for x in serials if x==os.getenv("SERIAL")]
|
||||
|
||||
panda_jungles = list([PandaJungle(x, claim=claim) for x in serials])
|
||||
panda_jungles = [PandaJungle(x, claim=claim) for x in serials]
|
||||
|
||||
if not len(panda_jungles):
|
||||
sys.exit("no panda jungles found")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
|
||||
[tool.ruff]
|
||||
select = ["E", "F", "W", "B"]
|
||||
ignore = ["W292", "E741"]
|
||||
select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF100", "A"]
|
||||
ignore = ["W292", "E741", "E402", "C408", "ISC003"]
|
||||
line-length = 160
|
||||
target-version="py311"
|
||||
flake8-implicit-str-concat.allow-multiline=false
|
||||
|
|
|
@ -409,7 +409,7 @@ class Panda:
|
|||
return usb_handle, usb_serial, bootstub, bcd
|
||||
|
||||
@classmethod
|
||||
def list(cls):
|
||||
def list(cls): # noqa: A003
|
||||
ret = cls.usb_list()
|
||||
ret += cls.spi_list()
|
||||
return list(set(ret))
|
||||
|
|
|
@ -59,7 +59,7 @@ class PandaDFU:
|
|||
return handle
|
||||
|
||||
@staticmethod
|
||||
def list() -> List[str]:
|
||||
def list() -> List[str]: # noqa: A003
|
||||
ret = PandaDFU.usb_list()
|
||||
ret += PandaDFU.spi_list()
|
||||
return list(set(ret))
|
||||
|
|
|
@ -8,7 +8,7 @@ class PandaSerial(object):
|
|||
self.panda.set_uart_baud(self.port, baud)
|
||||
self.buf = b""
|
||||
|
||||
def read(self, l=1): # noqa: E741
|
||||
def read(self, l=1):
|
||||
tt = self.panda.serial_read(self.port)
|
||||
if len(tt) > 0:
|
||||
self.buf += tt
|
||||
|
|
|
@ -6,13 +6,10 @@
|
|||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import argparse
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def get_test_string():
|
||||
return b"test" + os.urandom(10)
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import argparse
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def get_test_string():
|
||||
return b"test" + os.urandom(10)
|
||||
|
|
|
@ -5,13 +5,11 @@
|
|||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import argparse
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def get_test_string():
|
||||
return b"test" + os.urandom(10)
|
||||
|
|
|
@ -6,8 +6,7 @@ import time
|
|||
import select
|
||||
import codecs
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
setcolor = ["\033[1;32;40m", "\033[1;31;40m"]
|
||||
unsetcolor = "\033[00m"
|
||||
|
@ -24,7 +23,7 @@ if __name__ == "__main__":
|
|||
if os.getenv("SERIAL"):
|
||||
serials = [x for x in serials if x == os.getenv("SERIAL")]
|
||||
|
||||
pandas = list([Panda(x, claim=claim) for x in serials])
|
||||
pandas = [Panda(x, claim=claim) for x in serials]
|
||||
decoders = [codecs.getincrementaldecoder('utf-8')() for _ in pandas]
|
||||
|
||||
if not len(pandas):
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
# This script is intended to be used in conjunction with the echo_loopback_test.py test script from panda jungle.
|
||||
# It sends a reversed response back for every message received containing b"test".
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
"""Used to Reverse/Test ELM protocol auto detect and OBD message response without a car."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import sys
|
||||
import struct
|
||||
import binascii
|
||||
import time
|
||||
import threading
|
||||
from collections import deque
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def lin_checksum(dat):
|
||||
return sum(dat) % 0x100
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
WHITE_GMLAN_BUS = 3
|
||||
OTHER_GMLAN_BUS = 1
|
||||
|
|
|
@ -58,7 +58,7 @@ def init_all_pandas():
|
|||
|
||||
print(f"{len(_all_pandas)} total pandas")
|
||||
init_all_pandas()
|
||||
_all_panda_serials = list(sorted(_all_pandas.keys()))
|
||||
_all_panda_serials = sorted(_all_pandas.keys())
|
||||
|
||||
|
||||
def init_jungle():
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
power = 0
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -72,10 +72,10 @@ class PandaSafety(Protocol):
|
|||
def get_current_safety_mode(self) -> int: ...
|
||||
def get_current_safety_param(self) -> int: ...
|
||||
|
||||
def set_torque_meas(self, min: int, max: int) -> None: ... # pylint: disable=redefined-builtin
|
||||
def set_torque_meas(self, min: int, max: int) -> None: ... # noqa: A002
|
||||
def get_torque_meas_min(self) -> int: ...
|
||||
def get_torque_meas_max(self) -> int: ...
|
||||
def set_torque_driver(self, min: int, max: int) -> None: ... # pylint: disable=redefined-builtin
|
||||
def set_torque_driver(self, min: int, max: int) -> None: ... # noqa: A002
|
||||
def get_torque_driver_min(self) -> int: ...
|
||||
def get_torque_driver_max(self) -> int: ...
|
||||
def set_desired_torque_last(self, t: int) -> None: ...
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import argparse
|
||||
|
@ -9,8 +8,7 @@ import argparse
|
|||
from hexdump import hexdump
|
||||
from itertools import permutations
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def get_test_string():
|
||||
return b"test" + os.urandom(10)
|
||||
|
@ -25,7 +23,7 @@ def run_test(sleep_duration):
|
|||
run_test_w_pandas(pandas, sleep_duration)
|
||||
|
||||
def run_test_w_pandas(pandas, sleep_duration):
|
||||
h = list([Panda(x) for x in pandas])
|
||||
h = [Panda(x) for x in pandas]
|
||||
print("H", h)
|
||||
|
||||
for hh in h:
|
||||
|
|
|
@ -16,7 +16,7 @@ if JUNGLE:
|
|||
# Generate unique messages
|
||||
NUM_MESSAGES_PER_BUS = 10000
|
||||
messages = [bytes(struct.pack("Q", i)) for i in range(NUM_MESSAGES_PER_BUS)]
|
||||
tx_messages = list(itertools.chain.from_iterable(map(lambda msg: [[0xaa, None, msg, 0], [0xaa, None, msg, 1], [0xaa, None, msg, 2]], messages)))
|
||||
tx_messages = list(itertools.chain.from_iterable(([[0xaa, None, msg, 0], [0xaa, None, msg, 1], [0xaa, None, msg, 2]] for msg in messages)))
|
||||
|
||||
def flood_tx(panda):
|
||||
print('Sending!')
|
||||
|
@ -65,6 +65,6 @@ if __name__ == "__main__":
|
|||
|
||||
# Check if we received everything
|
||||
for bus in range(3):
|
||||
received_msgs = set(map(lambda m: bytes(m[2]), filter(lambda m, b=bus: m[3] == b, rx))) # type: ignore
|
||||
received_msgs = {bytes(m[2]) for m in filter(lambda m, b=bus: m[3] == b, rx)} # type: ignore
|
||||
dropped_msgs = set(messages).difference(received_msgs)
|
||||
print(f"Bus {bus} dropped msgs: {len(list(dropped_msgs))} / {len(messages)}")
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
if __name__ == "__main__":
|
||||
p = Panda()
|
||||
|
|
|
@ -987,7 +987,7 @@ class PandaSafetyTest(PandaSafetyTestBase):
|
|||
if attr.startswith('TestHonda'):
|
||||
# exceptions for common msgs across different hondas
|
||||
tx = list(filter(lambda m: m[0] not in [0x1FA, 0x30C, 0x33D], tx))
|
||||
all_tx.append(list([m[0], m[1], attr] for m in tx))
|
||||
all_tx.append([m[0], m[1], attr] for m in tx)
|
||||
|
||||
# make sure we got all the msgs
|
||||
self.assertTrue(len(all_tx) >= len(test_files)-1)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def get_test_string():
|
||||
return b"test" + os.urandom(10)
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import struct
|
||||
import time
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
if __name__ == "__main__":
|
||||
p = Panda()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import argparse
|
||||
|
@ -9,8 +8,7 @@ import argparse
|
|||
from hexdump import hexdump
|
||||
from itertools import permutations
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
|
||||
from panda import Panda # noqa: E402
|
||||
from panda import Panda
|
||||
|
||||
def get_test_string():
|
||||
return b"test" + os.urandom(10)
|
||||
|
@ -25,7 +23,7 @@ def run_test(sleep_duration):
|
|||
run_test_w_pandas(pandas, sleep_duration)
|
||||
|
||||
def run_test_w_pandas(pandas, sleep_duration):
|
||||
h = list([Panda(x) for x in pandas])
|
||||
h = [Panda(x) for x in pandas]
|
||||
print("H", h)
|
||||
|
||||
for hh in h:
|
||||
|
|
Loading…
Reference in New Issue