use mp_arg_validate_type instead of if None

This commit is contained in:
foamyguy 2021-10-09 13:10:17 -05:00
parent 6c00ab7c97
commit e8a2e4a62b
2 changed files with 2 additions and 8 deletions

View File

@ -975,10 +975,6 @@ msgstr ""
msgid "Expected a DigitalInOut"
msgstr ""
#: shared-bindings/displayio/FourWire.c
msgid "Expected a SPI"
msgstr ""
#: shared-bindings/_bleio/Characteristic.c
msgid "Expected a Service"
msgstr ""

View File

@ -78,10 +78,8 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
mp_obj_t spi = args[ARG_spi_bus].u_obj;
if (spi == mp_const_none) {
mp_raise_ValueError(translate("Expected a SPI"));
}
mp_obj_t spi = mp_arg_validate_type(args[ARG_spi_bus].u_obj, &busio_spi_type, MP_QSTR_spi_bus);
displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus;
self->base.type = &displayio_fourwire_type;