Skip to content

Commit 7aa6331

Browse files
committed
FIX: mypy linting
1 parent 935bc93 commit 7aa6331

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

copilot_translate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CopilotClient: # pylint: disable=too-few-public-methods
5555
headers: dict[str, str]
5656

5757
def __init__(self) -> None:
58-
self.api_key = os.getenv("GITHUB_COPILOT_TOKEN")
58+
self.api_key = os.getenv("GITHUB_COPILOT_TOKEN", "")
5959
if not self.api_key:
6060
msg = "GITHUB_COPILOT_TOKEN environment variable not set"
6161
raise ValueError(msg)

update_flight_controller_ids.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# Define the base directory to crawl
2020
BASE_DIR = "../ardupilot/libraries/AP_HAL_ChibiOS/hwdef/"
2121

22+
hwdef_dict = dict[str, tuple[int, int, int, str, str, str]]
23+
2224
logging.basicConfig(level="INFO", format="%(asctime)s - %(levelname)s - %(message)s")
2325

2426
# Add ../ardupilot/libraries/AP_HAL_ChibiOS/hwdef/scripts to the PYTHON path
@@ -50,8 +52,8 @@ def remove_suffixes(base_dirname: str, suffixes: list) -> str:
5052
return base_dirname
5153

5254

53-
def process_hwdef_files(base_directory: str) -> dict[str, tuple[int, int, int, str, str]]:
54-
hwdef_data: dict[str, tuple[int, int, int, str, str, str]] = {}
55+
def process_hwdef_files(base_directory: str) -> hwdef_dict:
56+
hwdef_data: hwdef_dict = {}
5557

5658
# Walk through the directory
5759
for dirpath, _dirnames, filenames in os.walk(base_directory):
@@ -72,16 +74,18 @@ def process_hwdef_files(base_directory: str) -> dict[str, tuple[int, int, int, s
7274
dirname = os.path.basename(dirpath)
7375
numeric_board_id = int(c.get_numeric_board_id())
7476
vid, pid = c.get_USB_IDs()
77+
vid = int(vid)
78+
pid = int(pid)
7579
vid_name = str(c.get_config("USB_STRING_MANUFACTURER", default="ArduPilot")).strip('"').strip("'")
7680
pid_name = str(c.get_config("USB_STRING_PRODUCT", default=dirname)).strip('"').strip("'")
77-
mcu_series = c.mcu_series
81+
mcu_series = str(c.mcu_series)
7882
hwdef_data[dirname] = (numeric_board_id, vid, pid, vid_name, pid_name, mcu_series)
7983
# Sort the dictionary by the (dirname) key, so that python 3.13 produces similar results to python 3.12
8084
return dict(sorted(hwdef_data.items(), key=lambda x: x[0].lower()))
8185

8286

8387
def create_dicts( # pylint: disable=too-many-locals
84-
hwdef_data: dict[str, tuple[int, int, int, str, str, str]],
88+
hwdef_data: hwdef_dict,
8589
) -> tuple[dict[int, str], dict[tuple[int, int], str], dict[int, str], dict[int, str], dict[int, str]]:
8690
vid_vendor_dict: dict[int, str] = {}
8791
vid_pid_product_dict: dict[tuple[int, int], str] = {}
@@ -223,7 +227,7 @@ def main() -> None:
223227
apj_board_id_vendor_dict: dict[int, str] = {}
224228
mcu_series_dict: dict[int, str] = {}
225229

226-
hwdef_data: dict[str, tuple[int, int, int, str, str]] = process_hwdef_files(BASE_DIR)
230+
hwdef_data: hwdef_dict = process_hwdef_files(BASE_DIR)
227231
vid_vendor_dict, vid_pid_product_dict, apj_board_id_name_dict, apj_board_id_vendor_dict, mcu_series_dict = create_dicts(
228232
hwdef_data
229233
)

0 commit comments

Comments
 (0)