8000 use mp_arg_validate_type instead of if None · fraziern/circuitpython@e8a2e4a · GitHub
[go: up one dir, main page]

Skip to content

Commit e8a2e4a

Browse files
committed
use mp_arg_validate_type instead of if None
1 parent 6c00ab7 commit e8a2e4a

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

locale/circuitpython.pot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,6 @@ msgstr ""
975975
msgid "Expected a DigitalInOut"
976976
msgstr ""
977977

978-
#: shared-bindings/displayio/FourWire.c
979-
msgid "Expected a SPI"
980-
msgstr ""
981-
982978
#: shared-bindings/_bleio/Characteristic.c
983979
msgid "Expected a Service"
984980
msgstr ""

shared-bindings/displayio/FourWire.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
7878
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
7979
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
8080

81-
mp_obj_t spi = args[ARG_spi_bus].u_obj;
82-
if (spi == mp_const_none) {
83-
mp_raise_ValueError(translate("Expected a SPI"));
84-
}
81+
mp_obj_t spi = mp_arg_validate_type(args[ARG_spi_bus].u_obj, &busio_spi_type, MP_QSTR_spi_bus);
82+
8583
displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus;
8684
self->base.type = &displayio_fourwire_type;
8785

0 commit comments

Comments
 (0)
0