Skip to content

Commit c798ce9

Browse files
authored
Fix test on rolling CI (#187)
1 parent 3da6c01 commit c798ce9

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

.github/workflows/ci.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
env:
19-
# Werror is not enabled on humble and iron because of gtest
2019
- ROS_DISTRO: rolling
2120
ROS_REPO: testing
22-
CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Werror
2321
- ROS_DISTRO: rolling
2422
ROS_REPO: main
25-
CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Werror
2623
- ROS_DISTRO: iron
2724
ROS_REPO: testing
2825
- ROS_DISTRO: iron

generate_parameter_library_py/generate_parameter_library_py/cpp_convertions.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from typing import List, Optional
2+
from typing import List, Union
33
from jinja2 import Template
44
from typeguard import typechecked
55
import os
@@ -108,18 +108,18 @@ def update_parameter_pass_validation(self) -> str:
108108
return ''
109109

110110
@typechecked
111-
def no_code(self, s: Optional[str]):
111+
def no_code(self, s: Union[None, str]):
112112
return ''
113113

114114
# value to c++ string conversion functions
115115
@typechecked
116-
def bool_to_str(self, cond: Optional[bool]):
116+
def bool_to_str(self, cond: Union[None, bool]):
117117
if cond is None:
118118
return ''
119119
return 'true' if cond else 'false'
120120

121121
@typechecked
122-
def float_to_str(self, num: Optional[float]):
122+
def float_to_str(self, num: Union[None, float]):
123123
if num is None:
124124
return ''
125125
str_num = str(num)
@@ -136,65 +136,65 @@ def float_to_str(self, num: Optional[float]):
136136
return str_num
137137

138138
@typechecked
139-
def int_to_str(self, num: Optional[int]):
139+
def int_to_str(self, num: Union[None, int]):
140140
if num is None:
141141
return ''
142142
return str(num)
143143

144144
@typechecked
145-
def str_to_str(self, s: Optional[str]):
145+
def str_to_str(self, s: Union[None, str]):
146146
if s is None:
147147
return ''
148148
return f'"{s}"'
149149

150150
@typechecked
151-
def bool_array_to_str(self, values: Optional[list]):
151+
def bool_array_to_str(self, values: Union[None, list]):
152152
if values is None:
153153
return ''
154154
return '{' + ', '.join(self.bool_to_str(x) for x in values) + '}'
155155

156156
@typechecked
157-
def float_array_to_str(self, values: Optional[list]):
157+
def float_array_to_str(self, values: Union[None, list]):
158158
if values is None:
159159
return ''
160160
return '{' + ', '.join(self.float_to_str(x) for x in values) + '}'
161161

162162
@typechecked
163-
def int_array_to_str(self, values: Optional[list]):
163+
def int_array_to_str(self, values: Union[None, list]):
164164
if values is None:
165165
return ''
166166
return '{' + ', '.join(self.int_to_str(x) for x in values) + '}'
167167

168168
@typechecked
169-
def str_array_to_str(self, s: Optional[list]):
169+
def str_array_to_str(self, s: Union[None, list]):
170170
if s is None:
171171
return ''
172172
return '{' + ', '.join(self.str_to_str(x) for x in s) + '}'
173173

174174
@typechecked
175-
def str_array_fixed_to_str(self, s: Optional[list]):
175+
def str_array_fixed_to_str(self, s: Union[None, list]):
176176
raise compile_error('not implemented')
177177

178178
@typechecked
179-
def str_fixed_to_str(self, s: Optional[str]):
179+
def str_fixed_to_str(self, s: Union[None, str]):
180180
if s is None:
181181
return ''
182182
return '{%s}' % self.str_to_str(s)
183183

184184
@typechecked
185-
def float_array_fixed_to_str(self, values: Optional[list]):
185+
def float_array_fixed_to_str(self, values: Union[None, list]):
186186
if values is None:
187187
return ''
188188
return '{{' + ', '.join(self.float_to_str(x) for x in values) + '}}'
189189

190190
@typechecked
191-
def int_array_fixed_to_str(self, values: Optional[list]):
191+
def int_array_fixed_to_str(self, values: Union[None, list]):
192192
if values is None:
193193
return ''
194194
return '{{' + ', '.join(self.int_to_str(x) for x in values) + '}}'
195195

196196
@typechecked
197-
def bool_array_fixed_to_str(self, values: Optional[list]):
197+
def bool_array_fixed_to_str(self, values: Union[None, list]):
198198
if values is None:
199199
return ''
200200
return '{{' + ', '.join(self.bool_to_str(x) for x in values) + '}}'

generate_parameter_library_py/generate_parameter_library_py/parse_yaml.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131

3232
from jinja2 import Template, Environment
3333
from typeguard import typechecked
34-
from typing import Any, List, Optional
34+
35+
# try to import TypeCheckError from typeguard. This was breaking and replaced TypeError in 3.0.0
36+
try:
37+
from typeguard import TypeCheckError
38+
except ImportError as e:
39+
# otherwise, use the old TypeError
40+
TypeCheckError = TypeError
41+
42+
from typing import Any, List, Union
3543
from yaml.parser import ParserError
3644
from yaml.scanner import ScannerError
3745
import os
@@ -190,7 +198,7 @@ def __init__(
190198
func = self.conversation.lang_str_value_func[self.defined_type]
191199
try:
192200
self.lang_str_value = func(default_value)
193-
except TypeError:
201+
except TypeCheckError:
194202
raise compile_error(
195203
f'Parameter {param_name} has incorrect type. Expected: {defined_type}, got: {self.get_yaml_type_from_python(default_value)}'
196204
)
@@ -314,7 +322,7 @@ class ValidationFunction:
314322
def __init__(
315323
self,
316324
function_name: str,
317-
arguments: Optional[List[Any]],
325+
arguments: Union[None, List[Any]],
318326
code_gen_variable: CodeGenVariableBase,
319327
):
320328
self.code_gen_variable = code_gen_variable

generate_parameter_library_py/generate_parameter_library_py/python_convertions.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from typing import List, Optional
2+
from typing import List, Union
33
from jinja2 import Template
44
from typeguard import typechecked
55
import os
@@ -107,18 +107,18 @@ def update_parameter_pass_validation(self) -> str:
107107
return ''
108108

109109
@typechecked
110-
def no_code(self, s: Optional[str]):
110+
def no_code(self, s: Union[None, str]):
111111
return ''
112112

113113
# value to c++ string conversion functions
114114
@typechecked
115-
def bool_to_str(self, cond: Optional[bool]):
115+
def bool_to_str(self, cond: Union[None, bool]):
116116
if cond is None:
117117
return ''
118118
return 'True' if cond else 'False'
119119

120120
@typechecked
121-
def float_to_str(self, num: Optional[float]):
121+
def float_to_str(self, num: Union[None, float]):
122122
if num is None:
123123
return ''
124124
str_num = str(num)
@@ -135,65 +135,65 @@ def float_to_str(self, num: Optional[float]):
135135
return str_num
136136

137137
@typechecked
138-
def int_to_str(self, num: Optional[int]):
138+
def int_to_str(self, num: Union[None, int]):
139139
if num is None:
140140
return ''
141141
return str(num)
142142

143143
@typechecked
144-
def str_to_str(self, s: Optional[str]):
144+
def str_to_str(self, s: Union[None, str]):
145145
if s is None:
146146
return ''
147147
return f'"{s}"'
148148

149149
@typechecked
150-
def bool_array_to_str(self, values: Optional[list]):
150+
def bool_array_to_str(self, values: Union[None, list]):
151151
if values is None:
152152
return ''
153153
return '[' + ', '.join(self.bool_to_str(x) for x in values) + ']'
154154

155155
@typechecked
156-
def float_array_to_str(self, values: Optional[list]):
156+
def float_array_to_str(self, values: Union[None, list]):
157157
if values is None:
158158
return ''
159159
return '[' + ', '.join(self.float_to_str(x) for x in values) + ']'
160160

161161
@typechecked
162-
def int_array_to_str(self, values: Optional[list]):
162+
def int_array_to_str(self, values: Union[None, list]):
163163
if values is None:
164164
return ''
165165
return '[' + ', '.join(self.int_to_str(x) for x in values) + ']'
166166

167167
@typechecked
168-
def str_array_to_str(self, s: Optional[list]):
168+
def str_array_to_str(self, s: Union[None, list]):
169169
if s is None:
170170
return ''
171171
return '[' + ', '.join(self.str_to_str(x) for x in s) + ']'
172172

173173
@typechecked
174-
def str_array_fixed_to_str(self, s: Optional[list]):
174+
def str_array_fixed_to_str(self, s: Union[None, list]):
175175
raise compile_error('not implemented')
176176

177177
@typechecked
178-
def str_fixed_to_str(self, s: Optional[str]):
178+
def str_fixed_to_str(self, s: Union[None, str]):
179179
if s is None:
180180
return ''
181181
return '%s' % self.str_to_str(s)
182182

183183
@typechecked
184-
def float_array_fixed_to_str(self, values: Optional[list]):
184+
def float_array_fixed_to_str(self, values: Union[None, list]):
185185
if values is None:
186186
return ''
187187
return '[' + ', '.join(self.float_to_str(x) for x in values) + ']'
188188

189189
@typechecked
190-
def int_array_fixed_to_str(self, values: Optional[list]):
190+
def int_array_fixed_to_str(self, values: Union[None, list]):
191191
if values is None:
192192
return ''
193193
return '[' + ', '.join(self.int_to_str(x) for x in values) + ']'
194194

195195
@typechecked
196-
def bool_array_fixed_to_str(self, values: Optional[list]):
196+
def bool_array_fixed_to_str(self, values: Union[None, list]):
197197
if values is None:
198198
return ''
199199
return '[' + ', '.join(self.bool_to_str(x) for x in values) + ']'

0 commit comments

Comments
 (0)