Search code examples
python-asynciopython-decoratorsmicropython

"decorated" keyword not implemented in micropython?


I'm trying to use the aiomqtt module ([https://github.com/sbtinstruments/aiomqtt]) in a micropython program on an ESP32-S3 system, but I get a syntax error on this statement in aiomqtt's client.py file:

async def decorated(self: ClientT, /, *args: P.args, **kwargs: P.kwargs) -> T:

I assume this is because "decorated" is not implemented in micropython, but I'm a bit unclear on Python decorators and hence not sure if that's the real issue. I would appreciate if someone more knowledgeable would comment.

I'm running micropython v1.20.0 (the latest release) and the same code runs fine on python 3.11.0 on my Mac. Is there a workaround that avoids use of "decorated"?


Solution

  • The positional-only argument syntax (/) was introduced in Python 3.8. MicroPython 1.20 does not support it.