Skip to content

Commit 20a96fd

Browse files
committed
Format stubs with ruff
1 parent 41091e4 commit 20a96fd

File tree

206 files changed

+1117
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+1117
-62
lines changed

shared-bindings/_bleio/Adapter.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
//| Use `_bleio.adapter` to access the sole instance already available.
6363
//| """
6464
//| ...
65+
//|
6566
static mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
6667
#if CIRCUITPY_BLEIO_HCI
6768
bleio_adapter_obj_t *self = common_hal_bleio_allocate_adapter_or_raise();
@@ -135,6 +136,7 @@ MP_PROPERTY_GETSET(bleio_adapter_address_obj,
135136
//| """name of the BLE adapter used once connected.
136137
//| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``,
137138
//| to make it easy to distinguish multiple CircuitPython boards."""
139+
//|
138140
static mp_obj_t _bleio_adapter_get_name(mp_obj_t self) {
139141
return MP_OBJ_FROM_PTR(common_hal_bleio_adapter_get_name(self));
140142
}
@@ -161,7 +163,7 @@ MP_PROPERTY_GETSET(bleio_adapter_name_obj,
161163
//| timeout: int = 0,
162164
//| interval: float = 0.1,
163165
//| tx_power: int = 0,
164-
//| directed_to: Optional[Address] = None
166+
//| directed_to: Optional[Address] = None,
165167
//| ) -> None:
166168
//| """Starts advertising until `stop_advertising` is called or if connectable, another device
167169
//| connects to us.
@@ -181,6 +183,7 @@ MP_PROPERTY_GETSET(bleio_adapter_name_obj,
181183
//| :param int tx_power: transmitter power while advertising in dBm
182184
//| :param Address directed_to: peer to advertise directly to"""
183185
//| ...
186+
//|
184187
static mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
185188
bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
186189

@@ -243,6 +246,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 1, bleio_
243246
//| def stop_advertising(self) -> None:
244247
//| """Stop sending advertising packets."""
245248
//| ...
249+
//|
246250
static mp_obj_t bleio_adapter_stop_advertising(mp_obj_t self_in) {
247251
bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in);
248252

@@ -262,7 +266,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapt
262266
//| interval: float = 0.1,
263267
//| window: float = 0.1,
264268
//| minimum_rssi: int = -80,
265-
//| active: bool = True
269+
//| active: bool = True,
266270
//| ) -> Iterable[ScanEntry]:
267271
//| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are
268272
//| filtered and returned separately.
@@ -282,6 +286,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapt
282286
//| :returns: an iterable of `_bleio.ScanEntry` objects
283287
//| :rtype: iterable"""
284288
//| ...
289+
//|
285290
static mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
286291
enum { ARG_prefixes, ARG_buffer_size, ARG_extended, ARG_timeout, ARG_interval, ARG_window, ARG_minimum_rssi, ARG_active };
287292
static const mp_arg_t allowed_args[] = {
@@ -346,6 +351,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_scan_obj, 1, bleio_adapter
346351
//| def stop_scan(self) -> None:
347352
//| """Stop the current scan."""
348353
//| ...
354+
//|
349355
static mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) {
350356
bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in);
351357

@@ -381,6 +387,7 @@ MP_PROPERTY_GETTER(bleio_adapter_connected_obj,
381387
//| connections: Tuple[Connection]
382388
//| """Tuple of active connections including those initiated through
383389
//| :py:meth:`_bleio.Adapter.connect`. (read-only)"""
390+
//|
384391
static mp_obj_t bleio_adapter_get_connections(mp_obj_t self) {
385392
return common_hal_bleio_adapter_get_connections(self);
386393
}
@@ -395,6 +402,7 @@ MP_PROPERTY_GETTER(bleio_adapter_connections_obj,
395402
//| :param Address address: The address of the peripheral to connect to
396403
//| :param float/int timeout: Try to connect for timeout seconds."""
397404
//| ...
405+
//|
398406
static mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
399407
bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
400408

@@ -418,6 +426,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 1, bleio_adapter_co
418426
//| """Erase all bonding information stored in flash memory."""
419427
//| ...
420428
//|
429+
//|
421430
static mp_obj_t bleio_adapter_erase_bonding(mp_obj_t self_in) {
422431
bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in);
423432

shared-bindings/_bleio/Address.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
//| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`,
2727
//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`."""
2828
//| ...
29+
//|
2930
static mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
3031
enum { ARG_address, ARG_address_type };
3132
static const mp_arg_t allowed_args[] = {
@@ -86,6 +87,7 @@ MP_PROPERTY_GETTER(bleio_address_address_bytes_obj,
8687
//|
8788
//| One of the integer values: `PUBLIC`, `RANDOM_STATIC`, `RANDOM_PRIVATE_RESOLVABLE`,
8889
//| or `RANDOM_PRIVATE_NON_RESOLVABLE`."""
90+
//|
8991
static mp_obj_t bleio_address_get_type(mp_obj_t self_in) {
9092
bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in);
9193

@@ -99,6 +101,7 @@ MP_PROPERTY_GETTER(bleio_address_type_obj,
99101
//| def __eq__(self, other: object) -> bool:
100102
//| """Two Address objects are equal if their addresses and address types are equal."""
101103
//| ...
104+
//|
102105
static mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
103106
switch (op) {
104107
// Two Addresses are equal if their address bytes and address_type are equal
@@ -124,6 +127,7 @@ static mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o
124127
//| def __hash__(self) -> int:
125128
//| """Returns a hash for the Address data."""
126129
//| ...
130+
//|
127131
static mp_obj_t bleio_address_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
128132
switch (op) {
129133
// Two Addresses are equal if their address bytes and address_type are equal
@@ -166,6 +170,7 @@ static void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
166170
//| RANDOM_PRIVATE_NON_RESOLVABLE: int
167171
//| """A randomly generated address that changes on every connection."""
168172
//|
173+
//|
169174
static const mp_rom_map_elem_t bleio_address_locals_dict_table[] = {
170175
{ MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_address_bytes_obj) },
171176
{ MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_address_type_obj) },

shared-bindings/_bleio/Attribute.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//| def __init__(self) -> None:
2020
//| """You cannot create an instance of :py:class:`~_bleio.Attribute`."""
2121
//| ...
22+
//|
2223

2324
static const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = {
2425

@@ -42,6 +43,7 @@ static const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = {
4243
//|
4344
//| SIGNED_WITH_MITM: int
4445
//| """security_mode: authenticated data signing, without man-in-the-middle protection"""
46+
//|
4547
//|
4648
{ MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SECURITY_MODE_NO_ACCESS) },
4749
{ MP_ROM_QSTR(MP_QSTR_OPEN), MP_ROM_INT(SECURITY_MODE_OPEN) },

shared-bindings/_bleio/Characteristic.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//| Remote Characteristic objects are created by `Connection.discover_remote_services()`
2626
//| as part of remote Services."""
2727
//| ...
28+
//|
2829

2930
//| @classmethod
3031
//| def add_to_service(
@@ -38,7 +39,7 @@
3839
//| max_length: int = 20,
3940
//| fixed_length: bool = False,
4041
//| initial_value: Optional[ReadableBuffer] = None,
41-
//| user_description: Optional[str] = None
42+
//| user_description: Optional[str] = None,
4243
//| ) -> Characteristic:
4344
//| """Create a new Characteristic object, and add it to this Service.
4445
//|
@@ -63,6 +64,7 @@
6364
//|
6465
//| :return: the new Characteristic."""
6566
//| ...
67+
//|
6668
static mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
6769
// class is arg[0], which we can ignore.
6870

@@ -143,6 +145,7 @@ static MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj,
143145
//| def deinit(self) -> None:
144146
//| """Deinitialises the Characteristic and releases any hardware resources for reuse."""
145147
//| ...
148+
//|
146149
static mp_obj_t bleio_characteristic_deinit(mp_obj_t self_in) {
147150
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
148151
common_hal_bleio_characteristic_deinit(self);
@@ -246,6 +249,7 @@ MP_PROPERTY_GETTER(bleio_characteristic_descriptors_obj,
246249

247250
//| service: Service
248251
//| """The Service this Characteristic is a part of."""
252+
//|
249253
static mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) {
250254
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
251255
check_for_deinit(self);
@@ -264,6 +268,7 @@ MP_PROPERTY_GETTER(bleio_characteristic_service_obj,
264268
//| :param float indicate: True if Characteristic should receive indications of remote writes
265269
//| """
266270
//| ...
271+
//|
267272
static mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
268273
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
269274
check_for_deinit(self);
@@ -312,6 +317,7 @@ static const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = {
312317
//|
313318
//| WRITE_NO_RESPONSE: int
314319
//| """property: clients may write this characteristic; no response will be sent back"""
320+
//|
315321
//|
316322
{ MP_ROM_QSTR(MP_QSTR_BROADCAST), MP_ROM_INT(CHAR_PROP_BROADCAST) },
317323
{ MP_ROM_QSTR(MP_QSTR_INDICATE), MP_ROM_INT(CHAR_PROP_INDICATE) },

shared-bindings/_bleio/CharacteristicBuffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self
3737
//| :param int buffer_size: Size of ring buffer that stores incoming data coming from client.
3838
//| Must be >= 1."""
3939
//| ...
40+
//|
4041
static mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
4142
enum { ARG_characteristic, ARG_timeout, ARG_buffer_size, };
4243
static const mp_arg_t allowed_args[] = {
@@ -95,6 +96,7 @@ static void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
9596
//| :return: the line read
9697
//| :rtype: int or None"""
9798
//| ...
99+
//|
98100

99101
// These three methods are used by the shared stream methods.
100102
static mp_uint_t bleio_characteristic_buffer_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
@@ -140,6 +142,7 @@ static mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r
140142

141143
//| in_waiting: int
142144
//| """The number of bytes in the input buffer, available to be read"""
145+
//|
143146
static mp_obj_t bleio_characteristic_buffer_obj_get_in_waiting(mp_obj_t self_in) {
144147
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
145148
check_for_deinit(self);
@@ -158,6 +161,7 @@ MP_PROPERTY_GETTER(bleio_characteristic_buffer_in_waiting_obj,
158161
//| def reset_input_buffer(self) -> None:
159162
//| """Discard any unread characters in the input buffer."""
160163
//| ...
164+
//|
161165
static mp_obj_t bleio_characteristic_buffer_obj_reset_input_buffer(mp_obj_t self_in) {
162166
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
163167
check_for_deinit(self);
@@ -170,6 +174,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_reset_input_buffer_
170174
//| """Disable permanently."""
171175
//| ...
172176
//|
177+
//|
173178
static mp_obj_t bleio_characteristic_buffer_deinit(mp_obj_t self_in) {
174179
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
175180
common_hal_bleio_characteristic_buffer_deinit(self);

shared-bindings/_bleio/Connection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void bleio_connection_ensure_connected(bleio_connection_obj_t *self) {
5656
//| def disconnect(self) -> None:
5757
//| """Disconnects from the remote peripheral. Does nothing if already disconnected."""
5858
//| ...
59+
//|
5960
static mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) {
6061
bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in);
6162
// common_hal_bleio_connection_disconnect() does nothing if already disconnected.
@@ -71,6 +72,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connecti
7172
//| **Limitation**: Currently ``bond``must be ``True``: bonding always occurs.
7273
//| """
7374
//| ...
75+
//|
7476
static mp_obj_t bleio_connection_pair(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
7577
bleio_connection_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
7678

@@ -117,6 +119,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_pair_obj, 1, bleio_connection
117119
//|
118120
//| :return: A tuple of `_bleio.Service` objects provided by the remote peripheral."""
119121
//| ...
122+
//|
120123
static mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
121124
bleio_connection_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
122125

@@ -188,6 +191,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connection_interval_obj, b
188191
//| But for a regular characteristic read or write, may be sent in multiple packets,
189192
//| so this limit does not apply."""
190193
//|
194+
//|
191195
static mp_obj_t bleio_connection_get_max_packet_length(mp_obj_t self_in) {
192196
bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in);
193197

shared-bindings/_bleio/Descriptor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
//| write_perm: int = Attribute.OPEN,
3636
//| max_length: int = 20,
3737
//| fixed_length: bool = False,
38-
//| initial_value: ReadableBuffer = b""
38+
//| initial_value: ReadableBuffer = b"",
3939
//| ) -> Descriptor:
4040
//| """Create a new Descriptor object, and add it to this Service.
4141
//|
@@ -55,6 +55,7 @@
5555
//|
5656
//| :return: the new Descriptor."""
5757
//| ...
58+
//|
5859
static mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
5960
// class is arg[0], which we can ignore.
6061

@@ -147,6 +148,7 @@ MP_PROPERTY_GETTER(bleio_descriptor_characteristic_obj,
147148
//| value: bytearray
148149
//| """The value of this descriptor."""
149150
//|
151+
//|
150152
static mp_obj_t bleio_descriptor_get_value(mp_obj_t self_in) {
151153
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
152154

shared-bindings/_bleio/PacketBuffer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//| characteristic: Characteristic,
2222
//| *,
2323
//| buffer_size: int,
24-
//| max_packet_size: Optional[int] = None
24+
//| max_packet_size: Optional[int] = None,
2525
//| ) -> None:
2626
//| """Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware
2727
//| outgoing writes. A packet's size is either the characteristic length or the maximum transmission
@@ -39,6 +39,7 @@
3939
//| :param int max_packet_size: Maximum size of packets. Overrides value from the characteristic.
4040
//| (Remote characteristics may not have the correct length.)"""
4141
//| ...
42+
//|
4243
static mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
4344
enum { ARG_characteristic, ARG_buffer_size, ARG_max_packet_size };
4445
static const mp_arg_t allowed_args[] = {
@@ -79,6 +80,7 @@ static void check_for_deinit(bleio_packet_buffer_obj_t *self) {
7980
//| :return: number of bytes read and stored into ``buf``
8081
//| :rtype: int"""
8182
//| ...
83+
//|
8284
static mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_obj) {
8385
bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
8486
check_for_deinit(self);
@@ -104,6 +106,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_
104106
//| :return: number of bytes written. May include header bytes when packet is empty.
105107
//| :rtype: int"""
106108
//| ...
109+
//|
107110
// TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending
108111
// one.
109112
static mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -149,6 +152,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet
149152
//| def deinit(self) -> None:
150153
//| """Disable permanently."""
151154
//| ...
155+
//|
152156
static mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) {
153157
bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
154158
common_hal_bleio_packet_buffer_deinit(self);
@@ -175,6 +179,7 @@ MP_PROPERTY_GETTER(bleio_packet_buffer_incoming_packet_length_obj,
175179
//| outgoing_packet_length: int
176180
//| """Maximum length in bytes of a packet we are writing."""
177181
//|
182+
//|
178183
static mp_obj_t bleio_packet_buffer_get_outgoing_packet_length(mp_obj_t self_in) {
179184
bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
180185

shared-bindings/_bleio/ScanEntry.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//| than the scan filtering which accepts any advertisements that match any of the prefixes
3131
//| where ``match_all`` is False."""
3232
//| ...
33+
//|
3334
static mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
3435
bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
3536

@@ -97,6 +98,7 @@ MP_PROPERTY_GETTER(bleio_scanentry_connectable_obj,
9798
//| scan_response: bool
9899
//| """True if the entry was a scan response. (read-only)"""
99100
//|
101+
//|
100102
static mp_obj_t scanentry_get_scan_response(mp_obj_t self_in) {
101103
bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
102104
return mp_obj_new_bool(common_hal_bleio_scanentry_get_scan_response(self));

shared-bindings/_bleio/ScanResults.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static mp_obj_t scanresults_iternext(mp_obj_t self_in) {
4040
//| """
4141
//| ...
4242
//|
43+
//|
4344

4445
MP_DEFINE_CONST_OBJ_TYPE(
4546
bleio_scanresults_type,

0 commit comments

Comments
 (0)