pimoroni / automation-hat

Python library and examples for the Pimoroni Automation HAT, pHAT and HAT Mini
https://shop.pimoroni.com/products/automation-hat
MIT License
122 stars 41 forks source link

hat-mini analog.py fails on Python3 < 3.6 #35

Closed ikkemaniac closed 4 years ago

ikkemaniac commented 4 years ago

Analog.py fails to run with a syntax error on Python3 < 3.6 because the following f-string requires python3 >= 3.6:

https://github.com/pimoroni/automation-hat/blob/1d5bd4f05b16daba5b00859e34fd4d6cedbf6f3f/examples/hat-mini/analog.py#L71

Fix: change: line above to:

draw.text((text_x, text_y + offset), '{:.2f}'.format(reading), font=font, fill=colour)

or to force users to py3 >=3.6 by changing this line to "3.6": https://github.com/pimoroni/automation-hat/blob/1d5bd4f05b16daba5b00859e34fd4d6cedbf6f3f/library/setup.py#L67

PS. would be good to mention somewhere the user needs to enable SPI and IC2 with raspi-config ...

Gadgetoid commented 4 years ago

Thanks for reporting this. Looks like the example uses both .format and f"" so canonicalising on .format is probably a sensible move.

In future I'm keen to drag all of our libraries kicking and screaming to Python 3.6+, but that will take some time.