Ruff: disallow non-openpilot imports (#29841)

pull/29844/head
Justin Newberry 2 years ago committed by GitHub
parent c96fe132e8
commit 110cfef1c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      pyproject.toml
  2. 2
      selfdrive/athena/athenad.py
  3. 2
      selfdrive/athena/tests/test_athenad.py
  4. 4
      selfdrive/controls/tests/test_leads.py
  5. 2
      system/swaglog.py

@ -167,7 +167,7 @@ build-backend = "poetry.core.masonry.api"
# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff]
select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF100", "A", "B"]
select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF100", "A", "B", "TID251"]
ignore = ["W292", "E741", "E402", "C408", "ISC003", "B027", "B024"]
line-length = 160
target-version="py311"
@ -180,3 +180,9 @@ exclude = [
"third_party",
]
flake8-implicit-str-concat.allow-multiline=false
[tool.ruff.flake8-tidy-imports.banned-api]
"selfdrive".msg = "Use openpilot.selfdrive"
"common".msg = "Use openpilot.common"
"system".msg = "Use openpilot.system"
"third_party".msg = "Use openpilot.third_party"
"tools".msg = "Use openpilot.tools"

@ -40,7 +40,7 @@ from openpilot.system.loggerd.xattr_cache import getxattr, setxattr
from openpilot.selfdrive.statsd import STATS_DIR
from openpilot.system.swaglog import cloudlog
from openpilot.system.version import get_commit, get_origin, get_short_branch, get_version
from selfdrive.hardware.hw import Paths
from openpilot.selfdrive.hardware.hw import Paths
# TODO: use socket constant when mypy recognizes this as a valid attribute

@ -21,7 +21,7 @@ from openpilot.selfdrive.athena import athenad
from openpilot.selfdrive.athena.athenad import MAX_RETRY_COUNT, dispatcher
from openpilot.selfdrive.athena.tests.helpers import MockWebsocket, MockParams, MockApi, EchoSocket, with_http_server
from cereal import messaging
from selfdrive.hardware.hw import Paths
from openpilot.selfdrive.hardware.hw import Paths
class TestAthenadMethods(unittest.TestCase):

@ -3,8 +3,8 @@ import unittest
import cereal.messaging as messaging
from selfdrive.test.process_replay import replay_process_with_name
from selfdrive.car.toyota.values import CAR as TOYOTA
from openpilot.selfdrive.test.process_replay import replay_process_with_name
from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
class TestLeads(unittest.TestCase):

@ -8,7 +8,7 @@ from logging.handlers import BaseRotatingHandler
import zmq
from openpilot.common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter
from system.hardware.hw import Paths
from openpilot.system.hardware.hw import Paths
def get_file_handler():

Loading…
Cancel
Save