0

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"?

4
  • What's the exact error you get? decorated doesn't need to be implemented, it's just an arbitrary function name, and you're showing us where it is being defined. Commented Aug 29, 2023 at 0:00
  • I'd rather guess micropython either doesn't support async, type annotations or /…?! Commented Aug 29, 2023 at 0:01
  • Traceback (most recent call last): File "<stdin>", line 1, in <module> File "weatherFeather.py", line 28, in <module> File "/lib/aiomqtt/__init__.py", line 2, in <module> File "/lib/aiomqtt/client.py", line 115 SyntaxError: invalid syntax Commented Aug 29, 2023 at 0:02
  • 1
    micropython definitely supports async. I use async functions all the time. Commented Aug 29, 2023 at 0:03

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @deceze! That's the problem and it's easy for me to work around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.