diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 01c70417..41ec546a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,13 +16,10 @@ jobs: fail-fast: false matrix: env: - # Werror is not enabled on humble and iron because of gtest - ROS_DISTRO: rolling ROS_REPO: testing - CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Werror - ROS_DISTRO: rolling ROS_REPO: main - CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Werror - ROS_DISTRO: iron ROS_REPO: testing - ROS_DISTRO: iron diff --git a/generate_parameter_library_py/generate_parameter_library_py/cpp_convertions.py b/generate_parameter_library_py/generate_parameter_library_py/cpp_convertions.py index 01cf6197..c1fa76da 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/cpp_convertions.py +++ b/generate_parameter_library_py/generate_parameter_library_py/cpp_convertions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from typing import List, Optional +from typing import List, Union from jinja2 import Template from typeguard import typechecked import os @@ -108,18 +108,18 @@ def update_parameter_pass_validation(self) -> str: return '' @typechecked - def no_code(self, s: Optional[str]): + def no_code(self, s: Union[None, str]): return '' # value to c++ string conversion functions @typechecked - def bool_to_str(self, cond: Optional[bool]): + def bool_to_str(self, cond: Union[None, bool]): if cond is None: return '' return 'true' if cond else 'false' @typechecked - def float_to_str(self, num: Optional[float]): + def float_to_str(self, num: Union[None, float]): if num is None: return '' str_num = str(num) @@ -136,65 +136,65 @@ def float_to_str(self, num: Optional[float]): return str_num @typechecked - def int_to_str(self, num: Optional[int]): + def int_to_str(self, num: Union[None, int]): if num is None: return '' return str(num) @typechecked - def str_to_str(self, s: Optional[str]): + def str_to_str(self, s: Union[None, str]): if s is None: return '' return f'"{s}"' @typechecked - def bool_array_to_str(self, values: Optional[list]): + def bool_array_to_str(self, values: Union[None, list]): if values is None: return '' return '{' + ', '.join(self.bool_to_str(x) for x in values) + '}' @typechecked - def float_array_to_str(self, values: Optional[list]): + def float_array_to_str(self, values: Union[None, list]): if values is None: return '' return '{' + ', '.join(self.float_to_str(x) for x in values) + '}' @typechecked - def int_array_to_str(self, values: Optional[list]): + def int_array_to_str(self, values: Union[None, list]): if values is None: return '' return '{' + ', '.join(self.int_to_str(x) for x in values) + '}' @typechecked - def str_array_to_str(self, s: Optional[list]): + def str_array_to_str(self, s: Union[None, list]): if s is None: return '' return '{' + ', '.join(self.str_to_str(x) for x in s) + '}' @typechecked - def str_array_fixed_to_str(self, s: Optional[list]): + def str_array_fixed_to_str(self, s: Union[None, list]): raise compile_error('not implemented') @typechecked - def str_fixed_to_str(self, s: Optional[str]): + def str_fixed_to_str(self, s: Union[None, str]): if s is None: return '' return '{%s}' % self.str_to_str(s) @typechecked - def float_array_fixed_to_str(self, values: Optional[list]): + def float_array_fixed_to_str(self, values: Union[None, list]): if values is None: return '' return '{{' + ', '.join(self.float_to_str(x) for x in values) + '}}' @typechecked - def int_array_fixed_to_str(self, values: Optional[list]): + def int_array_fixed_to_str(self, values: Union[None, list]): if values is None: return '' return '{{' + ', '.join(self.int_to_str(x) for x in values) + '}}' @typechecked - def bool_array_fixed_to_str(self, values: Optional[list]): + def bool_array_fixed_to_str(self, values: Union[None, list]): if values is None: return '' return '{{' + ', '.join(self.bool_to_str(x) for x in values) + '}}' diff --git a/generate_parameter_library_py/generate_parameter_library_py/parse_yaml.py b/generate_parameter_library_py/generate_parameter_library_py/parse_yaml.py index 1e8e7f48..7bb1fec6 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/parse_yaml.py +++ b/generate_parameter_library_py/generate_parameter_library_py/parse_yaml.py @@ -31,7 +31,15 @@ from jinja2 import Template, Environment from typeguard import typechecked -from typing import Any, List, Optional + +# try to import TypeCheckError from typeguard. This was breaking and replaced TypeError in 3.0.0 +try: + from typeguard import TypeCheckError +except ImportError as e: + # otherwise, use the old TypeError + TypeCheckError = TypeError + +from typing import Any, List, Union from yaml.parser import ParserError from yaml.scanner import ScannerError import os @@ -190,7 +198,7 @@ def __init__( func = self.conversation.lang_str_value_func[self.defined_type] try: self.lang_str_value = func(default_value) - except TypeError: + except TypeCheckError: raise compile_error( f'Parameter {param_name} has incorrect type. Expected: {defined_type}, got: {self.get_yaml_type_from_python(default_value)}' ) @@ -314,7 +322,7 @@ class ValidationFunction: def __init__( self, function_name: str, - arguments: Optional[List[Any]], + arguments: Union[None, List[Any]], code_gen_variable: CodeGenVariableBase, ): self.code_gen_variable = code_gen_variable diff --git a/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py b/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py index c171f6c9..0a09dd0d 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py +++ b/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from typing import List, Optional +from typing import List, Union from jinja2 import Template from typeguard import typechecked import os @@ -107,18 +107,18 @@ def update_parameter_pass_validation(self) -> str: return '' @typechecked - def no_code(self, s: Optional[str]): + def no_code(self, s: Union[None, str]): return '' # value to c++ string conversion functions @typechecked - def bool_to_str(self, cond: Optional[bool]): + def bool_to_str(self, cond: Union[None, bool]): if cond is None: return '' return 'True' if cond else 'False' @typechecked - def float_to_str(self, num: Optional[float]): + def float_to_str(self, num: Union[None, float]): if num is None: return '' str_num = str(num) @@ -135,65 +135,65 @@ def float_to_str(self, num: Optional[float]): return str_num @typechecked - def int_to_str(self, num: Optional[int]): + def int_to_str(self, num: Union[None, int]): if num is None: return '' return str(num) @typechecked - def str_to_str(self, s: Optional[str]): + def str_to_str(self, s: Union[None, str]): if s is None: return '' return f'"{s}"' @typechecked - def bool_array_to_str(self, values: Optional[list]): + def bool_array_to_str(self, values: Union[None, list]): if values is None: return '' return '[' + ', '.join(self.bool_to_str(x) for x in values) + ']' @typechecked - def float_array_to_str(self, values: Optional[list]): + def float_array_to_str(self, values: Union[None, list]): if values is None: return '' return '[' + ', '.join(self.float_to_str(x) for x in values) + ']' @typechecked - def int_array_to_str(self, values: Optional[list]): + def int_array_to_str(self, values: Union[None, list]): if values is None: return '' return '[' + ', '.join(self.int_to_str(x) for x in values) + ']' @typechecked - def str_array_to_str(self, s: Optional[list]): + def str_array_to_str(self, s: Union[None, list]): if s is None: return '' return '[' + ', '.join(self.str_to_str(x) for x in s) + ']' @typechecked - def str_array_fixed_to_str(self, s: Optional[list]): + def str_array_fixed_to_str(self, s: Union[None, list]): raise compile_error('not implemented') @typechecked - def str_fixed_to_str(self, s: Optional[str]): + def str_fixed_to_str(self, s: Union[None, str]): if s is None: return '' return '%s' % self.str_to_str(s) @typechecked - def float_array_fixed_to_str(self, values: Optional[list]): + def float_array_fixed_to_str(self, values: Union[None, list]): if values is None: return '' return '[' + ', '.join(self.float_to_str(x) for x in values) + ']' @typechecked - def int_array_fixed_to_str(self, values: Optional[list]): + def int_array_fixed_to_str(self, values: Union[None, list]): if values is None: return '' return '[' + ', '.join(self.int_to_str(x) for x in values) + ']' @typechecked - def bool_array_fixed_to_str(self, values: Optional[list]): + def bool_array_fixed_to_str(self, values: Union[None, list]): if values is None: return '' return '[' + ', '.join(self.bool_to_str(x) for x in values) + ']'