values: use union arguments (#32258)

* use get_args to reduce duplication

* clean up
old-commit-hash: f427427b5e085c7391b617e5c724c6b0326b24f1
This commit is contained in:
Shane Smiskol
2024-04-19 17:46:40 -07:00
committed by GitHub
parent 616b048906
commit 5ce8d5c4da
+3 -3
View File
@@ -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.chrysler.values import CAR as CHRYSLER
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
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}