Skip to content

Commit 93d2007

Browse files
committed
Added type hints to pulseio
1 parent a2c7e27 commit 93d2007

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

shared-bindings/pulseio/PWMOut.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
115115
return MP_OBJ_FROM_PTR(self);
116116
}
117117

118-
//| def deinit(self) -> Any:
118+
//| def deinit(self) -> None:
119119
//| """Deinitialises the PWMOut and releases any hardware resources for reuse."""
120120
//| ...
121121
//|
@@ -132,13 +132,13 @@ STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
132132
}
133133
}
134134

135-
//| def __enter__(self) -> Any:
135+
//| def __enter__(self) -> PWMOut:
136136
//| """No-op used by Context Managers."""
137137
//| ...
138138
//|
139139
// Provided by context manager helper.
140140

141-
//| def __exit__(self) -> Any:
141+
//| def __exit__(self) -> None:
142142
//| """Automatically deinitializes the hardware when exiting a context. See
143143
//| :ref:`lifetime-and-contextmanagers` for more info."""
144144
//| ...
@@ -150,7 +150,7 @@ STATIC mp_obj_t pulseio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args)
150150
}
151151
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pulseio_pwmout_obj___exit__);
152152

153-
//| duty_cycle: Any = ...
153+
//| duty_cycle: Optional[int] = ...
154154
//| """16 bit value that dictates how much of one cycle is high (1) versus low
155155
//| (0). 0xffff will always be high, 0 will always be low and 0x7fff will
156156
//| be half high and then half low.
@@ -186,7 +186,7 @@ const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
186186
(mp_obj_t)&mp_const_none_obj},
187187
};
188188

189-
//| frequency: Any = ...
189+
//| frequency: Optional[int] = ...
190190
//| """32 bit value that dictates the PWM frequency in Hertz (cycles per
191191
//| second). Only writeable when constructed with ``variable_frequency=True``.
192192
//|

shared-bindings/pulseio/PulseIn.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg
9696
return MP_OBJ_FROM_PTR(self);
9797
}
9898

99-
//| def deinit(self) -> Any:
99+
//| def deinit(self) -> None:
100100
//| """Deinitialises the PulseIn and releases any hardware resources for reuse."""
101101
//| ...
102102
//|
@@ -113,13 +113,13 @@ STATIC void check_for_deinit(pulseio_pulsein_obj_t *self) {
113113
}
114114
}
115115

116-
//| def __enter__(self) -> Any:
116+
//| def __enter__(self) -> PulseIn:
117117
//| """No-op used by Context Managers."""
118118
//| ...
119119
//|
120120
// Provided by context manager helper.
121121

122-
//| def __exit__(self) -> Any:
122+
//| def __exit__(self) -> None:
123123
//| """Automatically deinitializes the hardware when exiting a context. See
124124
//| :ref:`lifetime-and-contextmanagers` for more info."""
125125
//| ...
@@ -131,7 +131,7 @@ STATIC mp_obj_t pulseio_pulsein_obj___exit__(size_t n_args, const mp_obj_t *args
131131
}
132132
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulsein___exit___obj, 4, 4, pulseio_pulsein_obj___exit__);
133133

134-
//| def pause(self) -> Any:
134+
//| def pause(self) -> None:
135135
//| """Pause pulse capture"""
136136
//| ...
137137
//|
@@ -144,7 +144,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_pause(mp_obj_t self_in) {
144144
}
145145
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_pause_obj, pulseio_pulsein_obj_pause);
146146

147-
//| def resume(self, trigger_duration: int = 0) -> Any:
147+
//| def resume(self, trigger_duration: int = 0) -> None:
148148
//| """Resumes pulse capture after an optional trigger pulse.
149149
//|
150150
//| .. warning:: Using trigger pulse with a device that drives both high and
@@ -171,7 +171,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_ar
171171
}
172172
MP_DEFINE_CONST_FUN_OBJ_KW(pulseio_pulsein_resume_obj, 1, pulseio_pulsein_obj_resume);
173173

174-
//| def clear(self) -> Any:
174+
//| def clear(self) -> None:
175175
//| """Clears all captured pulses"""
176176
//| ...
177177
//|
@@ -184,7 +184,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_clear(mp_obj_t self_in) {
184184
}
185185
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_clear_obj, pulseio_pulsein_obj_clear);
186186

187-
//| def popleft(self) -> Any:
187+
//| def popleft(self) -> int:
188188
//| """Removes and returns the oldest read pulse."""
189189
//| ...
190190
//|
@@ -196,7 +196,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_popleft(mp_obj_t self_in) {
196196
}
197197
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_popleft_obj, pulseio_pulsein_obj_popleft);
198198

199-
//| maxlen: Any = ...
199+
//| maxlen: int = ...
200200
//| """The maximum length of the PulseIn. When len() is equal to maxlen,
201201
//| it is unclear which pulses are active and which are idle."""
202202
//|
@@ -215,7 +215,7 @@ const mp_obj_property_t pulseio_pulsein_maxlen_obj = {
215215
(mp_obj_t)&mp_const_none_obj},
216216
};
217217

218-
//| paused: Any = ...
218+
//| paused: bool = ...
219219
//| """True when pulse capture is paused as a result of :py:func:`pause` or an error during capture
220220
//| such as a signal that is too fast."""
221221
//|
@@ -234,7 +234,7 @@ const mp_obj_property_t pulseio_pulsein_paused_obj = {
234234
(mp_obj_t)&mp_const_none_obj},
235235
};
236236

237-
//| def __len__(self) -> Any:
237+
//| def __len__(self) -> Union[bool, int, None]:
238238
//| """Returns the current pulse length
239239
//|
240240
//| This allows you to::
@@ -254,7 +254,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
254254
}
255255
}
256256

257-
//| def __getitem__(self, index: Any) -> Any:
257+
//| def __getitem__(self, index: int) -> Optional[int]:
258258
//| """Returns the value at the given index or values in slice.
259259
//|
260260
//| This allows you to::

shared-bindings/pulseio/PulseOut.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
8181
return MP_OBJ_FROM_PTR(self);
8282
}
8383

84-
//| def deinit(self) -> Any:
84+
//| def deinit(self) -> None:
8585
//| """Deinitialises the PulseOut and releases any hardware resources for reuse."""
8686
//| ...
8787
//|
@@ -92,13 +92,13 @@ STATIC mp_obj_t pulseio_pulseout_deinit(mp_obj_t self_in) {
9292
}
9393
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulseout_deinit_obj, pulseio_pulseout_deinit);
9494

95-
//| def __enter__(self) -> Any:
95+
//| def __enter__(self) -> PulseOut:
9696
//| """No-op used by Context Managers."""
9797
//| ...
9898
//|
9999
// Provided by context manager helper.
100100

101-
//| def __exit__(self) -> Any:
101+
//| def __exit__(self) -> None:
102102
//| """Automatically deinitializes the hardware when exiting a context. See
103103
//| :ref:`lifetime-and-contextmanagers` for more info."""
104104
//| ...
@@ -110,7 +110,7 @@ STATIC mp_obj_t pulseio_pulseout_obj___exit__(size_t n_args, const mp_obj_t *arg
110110
}
111111
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulseout___exit___obj, 4, 4, pulseio_pulseout_obj___exit__);
112112

113-
//| def send(self, pulses: array.array) -> Any:
113+
//| def send(self, pulses: array.array) -> None:
114114
//| """Pulse alternating on and off durations in microseconds starting with on.
115115
//| ``pulses`` must be an `array.array` with data type 'H' for unsigned
116116
//| halfword (two bytes).

0 commit comments

Comments
 (0)