# Default (optional) -- for now take everything until the next comma
# TODO: ugh, do properly
- if signature.startswith('='):
- signature = signature[1:]
+ # The equals has spaces around since 2.3.0, preserve 2.2 compatibility.
+ # https://github.com/pybind/pybind11/commit/0826b3c10607c8d96e1d89dc819c33af3799a7b8
+ if signature.startswith(('=', ' = ')):
+ signature = signature[1 if signature[0] == '=' else 3:]
default = _pybind_default_value_rx.match(signature).group(0)
signature = signature[len(default):]
else:
('**kwargs', None, None),
], None))
- def test_default_values(self):
+ # https://github.com/pybind/pybind11/commit/0826b3c10607c8d96e1d89dc819c33af3799a7b8,
+ # released in 2.3.0. We want to support both, so test both.
+ def test_default_values_pybind22(self):
self.assertEqual(parse_pybind_signature(State({}),
'foo(a: float=1.0, b: str=\'hello\')'),
('foo', '', [
('b', 'str', '\'hello\''),
], None))
+ def test_default_values_pybind23(self):
+ self.assertEqual(parse_pybind_signature(State({}),
+ 'foo(a: float = 1.0, b: str = \'hello\')'),
+ ('foo', '', [
+ ('a', 'float', '1.0'),
+ ('b', 'str', '\'hello\''),
+ ], None))
+
def test_crazy_stuff(self):
self.assertEqual(parse_pybind_signature(State({}),
'foo(a: int, b: Math::Vector<4, UnsignedInt>)'),