Skip to content

Commit 79192b7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2bacb8f commit 79192b7

30 files changed

Lines changed: 86 additions & 93 deletions

benchmarks/tooltip_performance.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import statistics
1919
import time
2020
import tkinter as tk
21-
from typing import Callable, NamedTuple
21+
from collections.abc import Callable
22+
from typing import NamedTuple
2223

2324
try:
2425
import psutil

merge_pot_file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import tempfile
1919
from pathlib import Path
2020
from platform import system as platform_system
21-
from typing import Optional
2221

2322

2423
def process_locale_directory(locale_dir: Path, pot_file: Path, logger: logging.Logger) -> bool:
@@ -51,7 +50,7 @@ def process_locale_directory(locale_dir: Path, pot_file: Path, logger: logging.L
5150
return False
5251

5352

54-
def validate_and_get_tools(pot_file: Path, po_file: Path, logger: logging.Logger) -> tuple[bool, Optional[str], Optional[str]]:
53+
def validate_and_get_tools(pot_file: Path, po_file: Path, logger: logging.Logger) -> tuple[bool, str | None, str | None]:
5554
"""
5655
Validate inputs and determine msgmerge/msgattrib executable paths.
5756

scripts/batch_convert_motor_diagrams.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import shutil
2525
from io import BytesIO
2626
from pathlib import Path
27-
from typing import Union
2827

2928
from PIL import Image
3029
from selenium import webdriver
@@ -76,7 +75,7 @@ def crop_whitespace(image: Image.Image, margin: int = 5) -> Image.Image:
7675
return image.crop((left, top, right, bottom))
7776

7877

79-
def setup_firefox_service() -> tuple[Union[FirefoxService, None], str]:
78+
def setup_firefox_service() -> tuple[FirefoxService | None, str]:
8079
"""Set up Firefox service with geckodriver fallback logic."""
8180
# Create Firefox driver with fallback for geckodriver
8281
try:

scripts/calculate_code_statistics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import json
2323
import sys
2424
from pathlib import Path
25-
from typing import Any, Union
25+
from typing import Any
2626

2727
try:
2828
from pycloc import CLOC # ty: ignore[unresolved-import]
@@ -49,8 +49,8 @@
4949

5050
def get_cloc_stats(
5151
path: str,
52-
include_patterns: Union[list[str], None] = None,
53-
exclude_patterns: Union[list[str], None] = None,
52+
include_patterns: list[str] | None = None,
53+
exclude_patterns: list[str] | None = None,
5454
) -> dict[str, Any]:
5555
"""Get cloc statistics for a given path with optional include/exclude patterns."""
5656
cloc_cmd = CLOC().add_flag("--json")

scripts/crawl_ardupilot_wiki.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import logging
2020
import time
2121
from os import environ as os_environ
22-
from typing import Union
2322
from urllib.parse import urljoin, urlparse
2423

2524
import requests
@@ -68,7 +67,7 @@
6867

6968

7069
# pylint: disable=duplicate-code
71-
def get_env_proxies() -> Union[dict[str, str], None]:
70+
def get_env_proxies() -> dict[str, str] | None:
7271
proxies_env = {
7372
"http": os_environ.get("HTTP_PROXY") or os_environ.get("http_proxy"),
7473
"https": os_environ.get("HTTPS_PROXY") or os_environ.get("https_proxy"),

scripts/motor_diagrams_viewer_app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import tkinter as tk
2323
from pathlib import Path
2424
from tkinter import messagebox, ttk
25-
from typing import Optional
2625

2726
from batch_convert_motor_diagrams import crop_whitespace
2827
from PIL import Image
@@ -60,7 +59,7 @@ def __init__(
6059

6160
# Initialize variables
6261
self.svg_files: list[Path] = []
63-
self.current_image: Optional[tk.PhotoImage] = None
62+
self.current_image: tk.PhotoImage | None = None
6463
self.temp_dir = tempfile.mkdtemp()
6564
self.image_width = image_width
6665
self.image_height = image_height

tests/acceptance_battery_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"""
1515

1616
import tkinter as tk
17+
from collections.abc import Callable
1718
from math import nan
18-
from typing import Callable
1919
from unittest.mock import MagicMock
2020

2121
import pytest

tests/acceptance_bitmask_parameter_editor_usage_popup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
from __future__ import annotations
1414

15+
from collections.abc import Callable
1516
from dataclasses import dataclass
16-
from typing import TYPE_CHECKING, Callable, Optional, cast
17+
from typing import TYPE_CHECKING, Optional, cast
1718
from unittest.mock import MagicMock
1819

1920
from ardupilot_methodic_configurator.backend_filesystem_program_settings import USAGE_POPUP_WINDOWS

tests/acceptance_zip_for_forum_help.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from datetime import datetime, timezone
1919
from pathlib import Path
2020
from types import MethodType, SimpleNamespace
21-
from typing import Any, Optional, Union, cast
21+
from typing import Any, cast
2222
from unittest.mock import MagicMock, patch
2323
from zipfile import ZipFile
2424

@@ -94,7 +94,7 @@ def get_filesystem(parameter_editor: ParameterEditor) -> LocalFilesystem:
9494
def configure_filesystem(
9595
parameter_editor: ParameterEditor,
9696
vehicle_dir: Path,
97-
parameter_files: Optional[list[str]] = None,
97+
parameter_files: list[str] | None = None,
9898
) -> LocalFilesystem:
9999
"""Configure filesystem directory and parameter files for a test."""
100100
filesystem = get_filesystem(parameter_editor)
@@ -106,8 +106,8 @@ def configure_filesystem(
106106
def create_forum_help_zip(
107107
parameter_editor: ParameterEditor,
108108
*,
109-
show_info: Optional[MagicMock] = None,
110-
show_error: Optional[MagicMock] = None,
109+
show_info: MagicMock | None = None,
110+
show_error: MagicMock | None = None,
111111
) -> Path:
112112
"""Execute the public workflow helper and return the created zip path."""
113113
info_callback = show_info or MagicMock()
@@ -131,7 +131,7 @@ def create_forum_help_zip(
131131
def setup_zip_mock(
132132
parameter_editor: ParameterEditor,
133133
vehicle_dir: Path,
134-
file_parameters: Mapping[str, Union[ParDict, Mapping[str, Any], None]],
134+
file_parameters: Mapping[str, ParDict | Mapping[str, Any] | None],
135135
configuration_steps_filename: str = "configuration_steps_ArduCopter.json",
136136
) -> None:
137137
"""

tests/bdd_frontend_tkinter_show.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import tkinter as tk
1818
from collections.abc import Generator
1919
from tkinter import TclError
20-
from typing import Optional
2120
from unittest.mock import MagicMock, patch
2221

2322
import pytest
@@ -423,7 +422,7 @@ def test_system_returns_correct_monitor_bounds_for_platform( # pylint: disable=
423422
self,
424423
mock_widget: MagicMock,
425424
platform: str,
426-
platform_api_returns: Optional[MonitorBounds],
425+
platform_api_returns: MonitorBounds | None,
427426
fallback_returns: MonitorBounds,
428427
expected_bounds: MonitorBounds,
429428
) -> None:

0 commit comments

Comments
 (0)