Skip to content

Commit

Permalink
Use type_ for Parameter type attribute.
Browse files Browse the repository at this point in the history
Avoids collusion/confusion with type builtin.
  • Loading branch information
nuclearsandwich committed Aug 14, 2018
1 parent 40555f2 commit 3eea643
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions rclpy/rclpy/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,43 +92,43 @@ def __init__(self, name, type_, value=None):
if not type_.check(value):
raise ValueError("Type '{}' and value '{}' do not agree".format(type_, value))

self._type = type_
self._type_ = type_
self._name = name
self._value = value

@property
def name(self):
return self._name

@property # noqa: A003
def type(self):
return self._type
@property
def type_(self):
return self._type_

@property
def value(self):
return self._value

def get_descriptor(self):
return ParameterDescriptor(name=self.name, type=self.type.value)
return ParameterDescriptor(name=self.name, type=self.type_.value)

def get_parameter_value(self):
parameter_value = ParameterValue(type=self.type.value)
if Parameter.Type.BOOL == self.type:
parameter_value = ParameterValue(type=self.type_.value)
if Parameter.Type.BOOL == self.type_:
parameter_value.bool_value = self.value
elif Parameter.Type.INTEGER == self.type:
elif Parameter.Type.INTEGER == self.type_:
parameter_value.integer_value = self.value
elif Parameter.Type.DOUBLE == self.type:
elif Parameter.Type.DOUBLE == self.type_:
parameter_value.double_value = self.value
elif Parameter.Type.STRING == self.type:
elif Parameter.Type.STRING == self.type_:
parameter_value.string_value = self.value
elif Parameter.Type.BYTE_ARRAY == self.type:
elif Parameter.Type.BYTE_ARRAY == self.type_:
parameter_value.byte_array_value = self.value
elif Parameter.Type.BOOL_ARRAY == self.type:
elif Parameter.Type.BOOL_ARRAY == self.type_:
parameter_value.bool_array_value = self.value
elif Parameter.Type.INTEGER_ARRAY == self.type:
elif Parameter.Type.INTEGER_ARRAY == self.type_:
parameter_value.integer_array_value = self.value
elif Parameter.Type.DOUBLE_ARRAY == self.type:
elif Parameter.Type.DOUBLE_ARRAY == self.type_:
parameter_value.double_array_value = self.value
elif Parameter.Type.STRING_ARRAY == self.type:
elif Parameter.Type.STRING_ARRAY == self.type_:
parameter_value.string_array_value = self.value
return parameter_value
2 changes: 1 addition & 1 deletion rclpy/test/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_node_get_parameter(self):

def test_node_get_parameter_returns_parameter_not_set(self):
self.assertIsInstance(self.node.get_parameter('unset'), Parameter)
self.assertEqual(self.node.get_parameter('unset').type, Parameter.Type.NOT_SET)
self.assertEqual(self.node.get_parameter('unset').type_, Parameter.Type.NOT_SET)

def test_node_has_parameter_services(self):
service_names_and_types = self.node.get_service_names_and_types()
Expand Down

0 comments on commit 3eea643

Please sign in to comment.