Native method implementations that use mp_arg_parse_all() should be able to accept positional args that are labeled with keywords, but they are not.
Here is an example showing the issue with busio.SPI.
Constructor signature:
busio.SPI(clock: microcontroller.Pin, MOSI: Optional[microcontroller.Pin] = None, MISO: Optional[microcontroller.Pin] = None)
Method signature:
write(self, buffer: _typing.ReadableBuffer, *, start: int = 0, end: Optional[int] = None) → None
I would expect to be able to use or omit the clock, MOSI, and MISO keywords when passing args to the constructor.
I would also expect to be able to omit or include the buffer keyword when calling write().
>> import board,busio
>>> spi = busio.SPI(board.SCK, board.MOSI) # no keywords
>>> spi.deinit()
>>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI) # keywords supplied
>>> spi.try_lock()
True
>>> spi.write(b'abc') # no keyword
>>> spi.write(buffer=b'abc') # keyword should be allowed
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function missing 1 required positional arguments
We inherited some arg-parsing restrictions from MicroPython, but I don't remember that this is one of them, and it doesn't seem to be documented. Maybe I'm forgetting something.
Generalization of #5405.
Native method implementations that use
mp_arg_parse_all()should be able to accept positional args that are labeled with keywords, but they are not.Here is an example showing the issue with
busio.SPI.Constructor signature:
Method signature:
I would expect to be able to use or omit the
clock,MOSI, andMISOkeywords when passing args to the constructor.I would also expect to be able to omit or include the
bufferkeyword when callingwrite().We inherited some arg-parsing restrictions from MicroPython, but I don't remember that this is one of them, and it doesn't seem to be documented. Maybe I'm forgetting something.
Generalization of #5405.