diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab5ad9f..57fbe85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,24 +8,10 @@ repos: rev: v1.4.1 hooks: - id: mypy -- repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.282 hooks: - - id: flake8 - args: - - --select=F,E112,E113,E304,E501,E502,E701,E702,E703,E71,E72,E731,W191,W6 - - --max-line-length=240 - - --statistics -- repo: local - hooks: - - id: pylint - name: pylint - entry: pylint - language: system - types: [python] - exclude: 'site_scons/' - args: - - --disable=C,R,W0613,W0511,W0212,W0201,W0311,W0106,W0603,W0621,W0703,E1136 + - id: ruff - repo: local hooks: - id: cppcheck diff --git a/Dockerfile b/Dockerfile index 2ac356b..a1dabc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}" RUN pyenv install 3.11.4 && \ pyenv global 3.11.4 && \ pyenv rehash && \ - pip3 install --no-cache-dir pyyaml Cython scons pycapnp pre-commit pylint parameterized coverage numpy + pip3 install --no-cache-dir pyyaml Cython scons pycapnp pre-commit ruff parameterized coverage numpy WORKDIR /project/ RUN cd /tmp/ && \ diff --git a/messaging/__init__.py b/messaging/__init__.py index 5a863f1..efddea1 100644 --- a/messaging/__init__.py +++ b/messaging/__init__.py @@ -1,6 +1,7 @@ # must be built with scons -from .messaging_pyx import Context, Poller, SubSocket, PubSocket, SocketEventHandle, toggle_fake_events, set_fake_prefix, get_fake_prefix, delete_fake_prefix, wait_for_one_event # pylint: disable=no-name-in-module, import-error -from .messaging_pyx import MultiplePublishersError, MessagingError # pylint: disable=no-name-in-module, import-error +from .messaging_pyx import Context, Poller, SubSocket, PubSocket, SocketEventHandle, toggle_fake_events, \ + set_fake_prefix, get_fake_prefix, delete_fake_prefix, wait_for_one_event +from .messaging_pyx import MultiplePublishersError, MessagingError import os import capnp diff --git a/messaging/tests/test_fake.py b/messaging/tests/test_fake.py index 31191b4..6235e94 100644 --- a/messaging/tests/test_fake.py +++ b/messaging/tests/test_fake.py @@ -151,7 +151,7 @@ class TestFakeSockets(unittest.TestCase): bts = frame.to_bytes(8, 'little') pub_sock.send(bts) - + carState_handle = messaging.fake_event_handle("carState", enable=True) recv_called = carState_handle.recv_called_event recv_ready = carState_handle.recv_ready_event diff --git a/messaging/tests/test_messaging.py b/messaging/tests/test_messaging.py index 7173db9..a9579cb 100755 --- a/messaging/tests/test_messaging.py +++ b/messaging/tests/test_messaging.py @@ -169,7 +169,7 @@ class TestMessaging(unittest.TestCase): recvd = messaging.recv_sock(sub_sock) self.assertTrue(recvd is None) - # no wait and one msg in queue + # no wait and one msg in queue msg = random_carstate() pub_sock.send(msg.to_bytes()) time.sleep(0.01) @@ -187,7 +187,7 @@ class TestMessaging(unittest.TestCase): recvd = messaging.recv_one(sub_sock) self.assertTrue(recvd is None) - # one msg in queue + # one msg in queue msg = random_carstate() pub_sock.send(msg.to_bytes()) recvd = messaging.recv_one(sub_sock) @@ -205,7 +205,7 @@ class TestMessaging(unittest.TestCase): recvd = messaging.recv_one_or_none(sub_sock) self.assertTrue(recvd is None) - # one msg in queue + # one msg in queue msg = random_carstate() pub_sock.send(msg.to_bytes()) recvd = messaging.recv_one_or_none(sub_sock) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d08c406 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml +[tool.ruff] +select = ["E", "F", "W"] +ignore = ["W292", "E741"] +line-length = 160 +target-version="py311" \ No newline at end of file diff --git a/visionipc/__init__.py b/visionipc/__init__.py index 3e11bbb..7adfc58 100644 --- a/visionipc/__init__.py +++ b/visionipc/__init__.py @@ -1,4 +1,4 @@ -from cereal.visionipc.visionipc_pyx import VisionBuf, VisionIpcClient, VisionIpcServer, VisionStreamType, get_endpoint_name # pylint: disable=no-name-in-module, import-error +from cereal.visionipc.visionipc_pyx import VisionBuf, VisionIpcClient, VisionIpcServer, VisionStreamType, get_endpoint_name assert VisionBuf assert VisionIpcClient assert VisionIpcServer