temp ugly fix for micropython, using the when decorator with a function without arguments

This commit is contained in:
Fabio Pliger
2024-05-09 01:14:20 -05:00
parent 69bb8bac4f
commit 343f0590ed

View File

@@ -47,13 +47,14 @@ def when(event_type=None, selector=None):
wrapper = func
except AttributeError:
# TODO: this is currently an quick hack to get micropython working but we need
# to actually properly replace inspect.signature with something else
# TODO: this is very ugly hack to get micropython working because inspect.signature
# doesn't exist, but we need to actually properly replace inspect.signature.
# It may be actually better to not try any magic for now and raise the error
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except TypeError as e:
if "takes 0 positional arguments" in str(e):
if "takes" in str(e) and "positional arguments" in str(e):
return func()
raise