values: use union arguments (#32258)

* use get_args to reduce duplication

* clean up
pull/32261/head
Shane Smiskol 1 year ago committed by GitHub
parent ee01be71e1
commit f427427b5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      selfdrive/car/values.py

@ -1,4 +1,4 @@
from typing import cast from typing import get_args
from openpilot.selfdrive.car.body.values import CAR as BODY from openpilot.selfdrive.car.body.values import CAR as BODY
from openpilot.selfdrive.car.chrysler.values import CAR as CHRYSLER from openpilot.selfdrive.car.chrysler.values import CAR as CHRYSLER
from openpilot.selfdrive.car.ford.values import CAR as FORD from openpilot.selfdrive.car.ford.values import CAR as FORD
@ -14,6 +14,6 @@ from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
from openpilot.selfdrive.car.volkswagen.values import CAR as VOLKSWAGEN from openpilot.selfdrive.car.volkswagen.values import CAR as VOLKSWAGEN
Platform = BODY | CHRYSLER | FORD | GM | HONDA | HYUNDAI | MAZDA | MOCK | NISSAN | SUBARU | TESLA | TOYOTA | VOLKSWAGEN Platform = BODY | CHRYSLER | FORD | GM | HONDA | HYUNDAI | MAZDA | MOCK | NISSAN | SUBARU | TESLA | TOYOTA | VOLKSWAGEN
BRANDS = [BODY, CHRYSLER, FORD, GM, HONDA, HYUNDAI, MAZDA, MOCK, NISSAN, SUBARU, TESLA, TOYOTA, VOLKSWAGEN] BRANDS = get_args(Platform)
PLATFORMS: dict[str, Platform] = {str(platform): platform for brand in BRANDS for platform in cast(list[Platform], brand)} PLATFORMS: dict[str, Platform] = {str(platform): platform for brand in BRANDS for platform in brand}

Loading…
Cancel
Save