|
30 | 30 | from shutil import copytree as shutil_copytree |
31 | 31 | from shutil import rmtree as shutil_rmtree |
32 | 32 | from subprocess import SubprocessError, run |
33 | | -from typing import Any, Optional, Union |
| 33 | +from typing import Any |
34 | 34 | from zipfile import ZipFile |
35 | 35 |
|
36 | 36 | from argcomplete.completers import DirectoriesCompleter |
@@ -201,7 +201,7 @@ def _format_columns_sorted_numerically( # pylint: disable=too-many-locals |
201 | 201 | return [] |
202 | 202 |
|
203 | 203 | # Sort values numerically by key |
204 | | - def sort_key(item: tuple[str, Any]) -> tuple[int, Union[int, float, str]]: |
| 204 | + def sort_key(item: tuple[str, Any]) -> tuple[int, int | float | str]: |
205 | 205 | key = item[0] |
206 | 206 | try: |
207 | 207 | return (0, int(key)) # sort integers and floats together |
@@ -358,7 +358,7 @@ def read_params_from_files(self) -> dict[str, ParDict]: |
358 | 358 | logging_error(_("Error: %s is not a directory."), self.vehicle_dir) |
359 | 359 | return parameters |
360 | 360 |
|
361 | | - def compound_params(self, last_filename: Optional[str] = None, skip_default: bool = True) -> tuple[ParDict, Optional[str]]: |
| 361 | + def compound_params(self, last_filename: str | None = None, skip_default: bool = True) -> tuple[ParDict, str | None]: |
362 | 362 | """ |
363 | 363 | Compound parameters from multiple .param files into a single ParDict. |
364 | 364 |
|
@@ -399,7 +399,7 @@ def compound_params(self, last_filename: Optional[str] = None, skip_default: boo |
399 | 399 | return compound, first_config_step_filename |
400 | 400 |
|
401 | 401 | @staticmethod |
402 | | - def str_to_bool(s: str) -> Optional[bool]: |
| 402 | + def str_to_bool(s: str) -> bool | None: |
403 | 403 | """ |
404 | 404 | Converts a string representation of a boolean value to a boolean. |
405 | 405 |
|
@@ -606,7 +606,7 @@ def copy_template_files_to_new_vehicle_dir( # pylint: disable=too-many-argument |
606 | 606 | blank_change_reason: bool, |
607 | 607 | copy_vehicle_image: bool, |
608 | 608 | use_fc_params: bool = False, |
609 | | - fc_parameters: Optional[dict[str, float]] = None, |
| 609 | + fc_parameters: dict[str, float] | None = None, |
610 | 610 | ) -> str: |
611 | 611 | # Copy the template files to the new vehicle directory |
612 | 612 | try: |
@@ -662,7 +662,7 @@ def _transform_param_dict( |
662 | 662 | params: ParDict, |
663 | 663 | blank_change_reason: bool, |
664 | 664 | use_fc_params: bool, |
665 | | - fc_parameters: Optional[dict[str, float]], |
| 665 | + fc_parameters: dict[str, float] | None, |
666 | 666 | ) -> None: |
667 | 667 | """ |
668 | 668 | Apply in-place transformations to a parameter dict during template copy. |
@@ -845,7 +845,7 @@ def get_eval_variables(self) -> dict[str, dict[str, Any]]: |
845 | 845 | def calculate_derived_and_forced_param_changes( |
846 | 846 | self, |
847 | 847 | fc_param_names: list[str], |
848 | | - fc_parameters: Optional[dict[str, float]] = None, |
| 848 | + fc_parameters: dict[str, float] | None = None, |
849 | 849 | ) -> dict[str, ParDict]: |
850 | 850 | """ |
851 | 851 | Compute updated parameter values for all configuration files. |
@@ -966,8 +966,8 @@ def merge_forced_or_derived_parameters( |
966 | 966 | self, |
967 | 967 | filename: str, |
968 | 968 | new_parameters: dict[str, ParDict], |
969 | | - fc_param_names: Optional[list[str]], |
970 | | - target: Optional[ParDict] = None, |
| 969 | + fc_param_names: list[str] | None, |
| 970 | + target: ParDict | None = None, |
971 | 971 | ) -> bool: |
972 | 972 | """ |
973 | 973 | Merge forced or derived parameter values into a target parameter dict. |
|
0 commit comments