adafruit / adafruit/Adafruit_Learning_System_Guides
PyPortal_Hurricane_Tracker code can fail if movementDir JSON API call returns None
- Dominant language
- C
- Stars
- 1.1k
- Forks
- 806
- Avg merge
- 16h 52m
- Merged PRs (30d)
- 11
Description
PyPortal_Hurricane_Tracker code.py
**TypeError: can't convert NoneType to float line 136**
Caused by movementDir JSON being None if the hurricane has not moved.
This will skip the direction arrow but keep all the other graphics:
```
# add direction arrow
movement_dir = storm.get("### movementDir")
if movement_dir is not None:
angle = math.radians(float(movement_dir))
xd = x + int(ARROW_LENGTH * math.sin(angle))
yd = y - int(ARROW_LENGTH * math.cos(angle))
arrow = Line(x, y, xd, yd, color=ARROW_COLOR)
storm_gfx.append(arrow)
# add the storm graphics
storm_icons.append(storm_gfx)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Open PyPortal_Hurricane_Tracker code.py and inspect the movementDir handling around line 136. Check the JSON value before converting it to a float, then run the tracker to confirm that a missing direction skips only the direction arrow while preserving the other storm graphics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100