Skip to content

Commit

Permalink
Fix test on rolling CI (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
pac48 authored Aug 4, 2024
1 parent 3da6c01 commit c798ce9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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) + '}}'
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)}'
)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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) + ']'

0 comments on commit c798ce9

Please sign in to comment.