You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
webassembly: registered JS module function fails with named arguments #18190
With latest we tested all our integration tests and everything is fine except the fact we register utilities that accept objects/setup/init references and we are incapable of using the more Pythonic syntax at the Python level which used to work just like these work on globally exposed callbacks.
Something seems off when **kw args are around instead of dictionaries, we expect those named arguments to be passed as dictionary like these do already, and have done, for a while, thanks.
Observed behaviour
The error is thrown for no concrete reason but it's also misleading as it passes two args if no named argument is ued.
Additional Information
@dpgeorge is already aware of this issue which has now been formalized.
For the record TypeError: function expected at most 1 arguments, got 2 is a correct error message, it means that the function takes at most 1 argument, but was called with 2. Eg (lambda a:0)(1, 2) would give that error message, also under CPython.
For the record TypeError: function expected at most 1 arguments, got 2 is a correct error message
well, test('a', { 'b': 'c' }) uses two arguments and just works, so it surprises me test('a', b = 'c') considers test as a function that accepts only one argument, when it results into test('a', { 'b': 'c' }) on the other side like the ok function demonstrates.
That's the misleading / gotcha I was referring to, thanks for confirming and taking a look ... it's probably the only thing that keeps blocking us from updating to latest MicroPython with all its goodness backed in!
Thanks, that looks great and well tested, all expectations will be met, please do publish to npm once it's green and merged so we can finally update MicroPython 🙏
Activity
dpgeorge commentedon Oct 2, 2025
Thanks, I can reproduce the issue.
For the record
TypeError: function expected at most 1 arguments, got 2is a correct error message, it means that the function takes at most 1 argument, but was called with 2. Eg(lambda a:0)(1, 2)would give that error message, also under CPython.WebReflection commentedon Oct 2, 2025
well,
test('a', { 'b': 'c' })uses two arguments and just works, so it surprises metest('a', b = 'c')considerstestas a function that accepts only one argument, when it results intotest('a', { 'b': 'c' })on the other side like theokfunction demonstrates.That's the misleading / gotcha I was referring to, thanks for confirming and taking a look ... it's probably the only thing that keeps blocking us from updating to latest MicroPython with all its goodness backed in!
dpgeorge commentedon Oct 2, 2025
Should be fixed by #18191.
WebReflection commentedon Oct 2, 2025
Thanks, that looks great and well tested, all expectations will be met, please do publish to npm once it's green and merged so we can finally update MicroPython 🙏
edit never mind, we're on pyscript/polyscript#153