Skip to content

Commit e518221

Browse files
authored
Merge pull request #2913 from polkapolka/DigitalInOutTypeHints
Digital In Out Type Hints
2 parents 2addfff + c6406c7 commit e518221

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

shared-bindings/digitalio/DigitalInOut.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type,
7171
return MP_OBJ_FROM_PTR(self);
7272
}
7373

74-
//| def deinit(self, ) -> Any:
74+
//| def deinit(self) -> None:
7575
//| """Turn off the DigitalInOut and release the pin for other use."""
7676
//| ...
7777
//|
@@ -82,13 +82,13 @@ STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) {
8282
}
8383
MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalinout_obj_deinit);
8484

85-
//| def __enter__(self, ) -> Any:
85+
//| def __enter__(self, ) -> DigitalInOut:
8686
//| """No-op used by Context Managers."""
8787
//| ...
8888
//|
8989
// Provided by context manager helper.
9090

91-
//| def __exit__(self, ) -> Any:
91+
//| def __exit__(self, ) -> None:
9292
//| """Automatically deinitializes the hardware when exiting a context. See
9393
//| :ref:`lifetime-and-contextmanagers` for more info."""
9494
//| ...
@@ -106,12 +106,13 @@ STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) {
106106
}
107107
}
108108

109-
//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> Any:
109+
//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> None:
110110
//| """Set the drive mode and value and then switch to writing out digital
111111
//| values.
112112
//|
113113
//| :param bool value: default value to set upon switching
114-
//| :param ~digitalio.DriveMode drive_mode: drive mode for the output"""
114+
//| :param ~digitalio.DriveMode drive_mode: drive mode for the output
115+
//| """
115116
//| ...
116117
//|
117118
STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -135,7 +136,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_
135136
}
136137
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output);
137138

138-
//| def switch_to_input(self, pull: Pull = None) -> Any:
139+
//| def switch_to_input(self, pull: Pull = None) -> None:
139140
//| """Set the pull and then switch to read in digital values.
140141
//|
141142
//| :param Pull pull: pull configuration for the input
@@ -162,6 +163,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o
162163
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
163164
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
164165

166+
165167
digitalio_pull_t pull = PULL_NONE;
166168
if (args[ARG_pull].u_rom_obj == &digitalio_pull_up_obj) {
167169
pull = PULL_UP;
@@ -174,7 +176,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o
174176
}
175177
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_input_obj, 1, digitalio_digitalinout_switch_to_input);
176178

177-
//| direction: Any = ...
179+
//| direction: Direction = ...
178180
//| """The direction of the pin.
179181
//|
180182
//| Setting this will use the defaults from the corresponding
@@ -220,7 +222,7 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = {
220222
(mp_obj_t)&mp_const_none_obj},
221223
};
222224

223-
//| value: Any = ...
225+
//| value: Bool = ...
224226
//| """The digital logic level of the pin."""
225227
//|
226228
STATIC mp_obj_t digitalio_digitalinout_obj_get_value(mp_obj_t self_in) {
@@ -250,7 +252,7 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = {
250252
(mp_obj_t)&mp_const_none_obj},
251253
};
252254

253-
//| drive_mode: Any = ...
255+
//| drive_mode: DriveMode = ...
254256
//| """The pin drive mode. One of:
255257
//|
256258
//| - `digitalio.DriveMode.PUSH_PULL`
@@ -294,7 +296,7 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = {
294296
(mp_obj_t)&mp_const_none_obj},
295297
};
296298

297-
//| pull: Any = ...
299+
//| pull: Optional[Pull] = ...
298300
//| """The pin pull direction. One of:
299301
//|
300302
//| - `digitalio.Pull.UP`

0 commit comments

Comments
 (0)