TL;DR: pros randomly ceased to upload, problem was fixed by modifying pros source code. Is there a better way?
The first time I tried to upload code via pros, everything worked fine. After satisfying myself with the knowledge everything was working properly, I closed my laptop and went to work on something else. No less 45 minutes later, I return and attempt to upload once more. However, this time I am greeted by the following message:
$ sudo pros upload [INSERT]
ERROR - pros.cli.upload:upload - <flag 'BrainFlags'> has no members defined - pros-cli version:3.4.3
File "/usr/lib/python3.11/enum.py", line 1115, in __new__
raise TypeError("%r has no members defined" % cls)
TypeError: <flag 'BrainFlags'> has no members defined
I tried some of the various options provided me, but nothing seemed to help. Eventually, in a moment of desperation, I tried running:
$ grep -rI "BrainFlags" /usr/lib/python3.11/site-packages/pros
/usr/lib/python3.11/site-packages/pros/serial/devices/vex/v5_device.py: class BrainFlags(IntFlag):
/usr/lib/python3.11/site-packages/pros/serial/devices/vex/v5_device.py: flag_map = {Product.BRAIN: BrainFlags, Product.CONTROLLER: ControllerFlags}
And opened that file in my editor. There I found:
class BrainFlags(IntFlag):
pass
class ControllerFlags(IntFlag):
CONNECTED = 0x02
flag_map = {Product.BRAIN: BrainFlags, Product.CONTROLLER: ControllerFlags}
From my minimal python knowledge and the content of the error message, it seemed it was complaining the BrainFlags
class had no fields (I don’t know what the pass
keyword does). Not expecting much, I tried adding:
class BrainFlags(IntFlag):
EMPTY = 0x10
# pass
And, miraculously, it worked!
I post this in hopes that a more elegant solution exists, and that others with a similar problem may find it.