-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert list type to tuple in frozen classes (Fixes #117) #129
Conversation
houston/mission.py
Outdated
@@ -20,21 +20,21 @@ class Mission(object): | |||
configuration = attr.ib(type=Configuration) | |||
environment = attr.ib(type=Environment) | |||
initial_state = attr.ib(type=State) | |||
commands = attr.ib(type=List[Command]) # FIXME | |||
commands = attr.ib(type=Tuple[Command]) # FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a converter to transform a list (or tuple) into a tuple.
See: http://www.attrs.org/en/stable/init.html#converters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I didn't know that exists.
@@ -167,15 +167,15 @@ def generate_with_se(sut, initial, environment, config, mission): | |||
sut = houston.ardu.ArduCopter(snapshot, config) | |||
|
|||
# mission description | |||
cmds = [ | |||
cmds = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor point: It should be possible to pass a list to the constructor; the constructor should transform the list into a tuple.
houston/mission.py
Outdated
@@ -20,21 +21,22 @@ class Mission(object): | |||
configuration = attr.ib(type=Configuration) | |||
environment = attr.ib(type=Environment) | |||
initial_state = attr.ib(type=State) | |||
commands = attr.ib(type=List[Command]) # FIXME | |||
commands = attr.ib(type=Union[List[Command], Tuple[Command]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type
property specifies the type of the values that are used by that attribute. To avoid misleading the static analysis, type
should be Tuple[Command]
in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a small fix to the type used by two attributes.
houston/mission.py
Outdated
@@ -72,13 +74,14 @@ class MissionOutcome(object): | |||
a mission. | |||
""" | |||
passed = attr.ib(type=bool) | |||
outcomes = attr.ib(type=List[CommandOutcome]) | |||
outcomes = attr.ib(type=Union[List[CommandOutcome], Tuple[CommandOutcome]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
No description provided.