Skip to content

Commit

Permalink
Dot get value from dict as it seems a bit safer
Browse files Browse the repository at this point in the history
  • Loading branch information
eheinrich committed Mar 10, 2020
1 parent 8f8a078 commit ef06e1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion observation_portal/requestgroups/target_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, target):
'epoch', 'hour_angle'
)

if target['type'] == 'HOUR_ANGLE':
if target.get('type') == 'HOUR_ANGLE':
self.required_fields = ('hour_angle', 'dec')
else:
self.required_fields = ('ra', 'dec')
Expand Down

1 comment on commit ef06e1e

@phycodurus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just thinking this through: if target has no 'type' key, then

  • there'll be no KeyError,
  • target.get('type') will return None, which evals to False, so
  • required_fields will be ('ra', 'dec')
    So, if I'm thinking about this correctly, we're sort of implying that if there's no type key for this ICRSTargetHelper target, then the default is ICRS, which makes sense and works for external API clients.

Please sign in to comment.