micropython-stubber 1.23.1__py3-none-any.whl → 1.23.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.2.dist-info}/LICENSE +30 -30
- {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.2.dist-info}/METADATA +32 -15
- micropython_stubber-1.23.2.dist-info/RECORD +158 -0
- micropython_stubber-1.23.2.dist-info/entry_points.txt +5 -0
- mpflash/README.md +220 -194
- mpflash/libusb_flash.ipynb +203 -203
- mpflash/mpflash/add_firmware.py +98 -98
- mpflash/mpflash/ask_input.py +236 -236
- mpflash/mpflash/basicgit.py +284 -284
- mpflash/mpflash/bootloader/__init__.py +2 -2
- mpflash/mpflash/bootloader/activate.py +60 -60
- mpflash/mpflash/bootloader/detect.py +82 -82
- mpflash/mpflash/bootloader/manual.py +101 -101
- mpflash/mpflash/bootloader/micropython.py +12 -12
- mpflash/mpflash/bootloader/touch1200.py +36 -36
- mpflash/mpflash/cli_download.py +129 -129
- mpflash/mpflash/cli_flash.py +224 -219
- mpflash/mpflash/cli_group.py +111 -111
- mpflash/mpflash/cli_list.py +87 -81
- mpflash/mpflash/cli_main.py +39 -39
- mpflash/mpflash/common.py +210 -165
- mpflash/mpflash/config.py +44 -44
- mpflash/mpflash/connected.py +96 -78
- mpflash/mpflash/download.py +364 -364
- mpflash/mpflash/downloaded.py +130 -130
- mpflash/mpflash/errors.py +9 -9
- mpflash/mpflash/flash/__init__.py +55 -55
- mpflash/mpflash/flash/esp.py +59 -59
- mpflash/mpflash/flash/stm32.py +19 -19
- mpflash/mpflash/flash/stm32_dfu.py +104 -104
- mpflash/mpflash/flash/uf2/__init__.py +88 -88
- mpflash/mpflash/flash/uf2/boardid.py +15 -15
- mpflash/mpflash/flash/uf2/linux.py +136 -130
- mpflash/mpflash/flash/uf2/macos.py +42 -42
- mpflash/mpflash/flash/uf2/uf2disk.py +12 -12
- mpflash/mpflash/flash/uf2/windows.py +43 -43
- mpflash/mpflash/flash/worklist.py +170 -170
- mpflash/mpflash/list.py +106 -99
- mpflash/mpflash/logger.py +41 -41
- mpflash/mpflash/mpboard_id/__init__.py +93 -93
- mpflash/mpflash/mpboard_id/add_boards.py +251 -251
- mpflash/mpflash/mpboard_id/board.py +37 -37
- mpflash/mpflash/mpboard_id/board_id.py +86 -86
- mpflash/mpflash/mpboard_id/store.py +43 -43
- mpflash/mpflash/mpremoteboard/__init__.py +266 -222
- mpflash/mpflash/mpremoteboard/mpy_fw_info.py +141 -141
- mpflash/mpflash/mpremoteboard/runner.py +140 -140
- mpflash/mpflash/vendor/click_aliases.py +91 -91
- mpflash/mpflash/vendor/dfu.py +165 -165
- mpflash/mpflash/vendor/pydfu.py +605 -605
- mpflash/mpflash/vendor/readme.md +2 -2
- mpflash/mpflash/versions.py +135 -135
- mpflash/poetry.lock +1599 -1599
- mpflash/pyproject.toml +65 -65
- mpflash/stm32_udev_rules.md +62 -62
- stubber/__init__.py +3 -3
- stubber/board/board_info.csv +193 -193
- stubber/board/boot.py +34 -34
- stubber/board/createstubs.py +1004 -986
- stubber/board/createstubs_db.py +826 -825
- stubber/board/createstubs_db_min.py +332 -331
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_lvgl.py +741 -741
- stubber/board/createstubs_lvgl_min.py +741 -741
- stubber/board/createstubs_mem.py +767 -766
- stubber/board/createstubs_mem_min.py +307 -306
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +295 -294
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/board/fw_info.py +141 -141
- stubber/board/info.py +183 -183
- stubber/board/main.py +19 -19
- stubber/board/modulelist.txt +247 -247
- stubber/board/pyrightconfig.json +34 -34
- stubber/bulk/mcu_stubber.py +437 -454
- stubber/codemod/_partials/__init__.py +48 -48
- stubber/codemod/_partials/db_main.py +147 -147
- stubber/codemod/_partials/lvgl_main.py +77 -77
- stubber/codemod/_partials/modules_reader.py +80 -80
- stubber/codemod/add_comment.py +53 -53
- stubber/codemod/add_method.py +65 -65
- stubber/codemod/board.py +317 -317
- stubber/codemod/enrich.py +151 -145
- stubber/codemod/merge_docstub.py +284 -284
- stubber/codemod/modify_list.py +54 -54
- stubber/codemod/utils.py +56 -56
- stubber/commands/build_cmd.py +94 -94
- stubber/commands/cli.py +49 -55
- stubber/commands/clone_cmd.py +78 -78
- stubber/commands/config_cmd.py +29 -29
- stubber/commands/enrich_folder_cmd.py +71 -71
- stubber/commands/get_core_cmd.py +71 -71
- stubber/commands/get_docstubs_cmd.py +92 -89
- stubber/commands/get_frozen_cmd.py +117 -114
- stubber/commands/get_mcu_cmd.py +102 -61
- stubber/commands/merge_cmd.py +66 -66
- stubber/commands/publish_cmd.py +118 -118
- stubber/commands/stub_cmd.py +31 -31
- stubber/commands/switch_cmd.py +62 -62
- stubber/commands/variants_cmd.py +48 -48
- stubber/cst_transformer.py +178 -178
- stubber/data/board_info.csv +193 -193
- stubber/data/board_info.json +1729 -1729
- stubber/data/micropython_tags.csv +15 -15
- stubber/data/requirements-core-micropython.txt +38 -38
- stubber/data/requirements-core-pycopy.txt +39 -39
- stubber/downloader.py +37 -36
- stubber/freeze/common.py +72 -68
- stubber/freeze/freeze_folder.py +69 -69
- stubber/freeze/freeze_manifest_2.py +126 -113
- stubber/freeze/get_frozen.py +131 -127
- stubber/get_cpython.py +112 -101
- stubber/get_lobo.py +59 -59
- stubber/minify.py +423 -419
- stubber/publish/bump.py +86 -86
- stubber/publish/candidates.py +275 -256
- stubber/publish/database.py +18 -18
- stubber/publish/defaults.py +40 -40
- stubber/publish/enums.py +24 -24
- stubber/publish/helpers.py +29 -29
- stubber/publish/merge_docstubs.py +136 -130
- stubber/publish/missing_class_methods.py +51 -49
- stubber/publish/package.py +150 -146
- stubber/publish/pathnames.py +51 -51
- stubber/publish/publish.py +120 -120
- stubber/publish/pypi.py +42 -38
- stubber/publish/stubpackage.py +1055 -1027
- stubber/rst/__init__.py +9 -9
- stubber/rst/classsort.py +78 -77
- stubber/rst/lookup.py +533 -530
- stubber/rst/output_dict.py +401 -401
- stubber/rst/reader.py +814 -814
- stubber/rst/report_return.py +77 -69
- stubber/rst/rst_utils.py +541 -540
- stubber/stubber.py +38 -38
- stubber/stubs_from_docs.py +90 -90
- stubber/tools/manifestfile.py +654 -654
- stubber/tools/readme.md +6 -6
- stubber/update_fallback.py +117 -117
- stubber/update_module_list.py +123 -123
- stubber/utils/__init__.py +6 -6
- stubber/utils/config.py +137 -125
- stubber/utils/makeversionhdr.py +54 -54
- stubber/utils/manifest.py +90 -90
- stubber/utils/post.py +80 -79
- stubber/utils/repos.py +156 -150
- stubber/utils/stubmaker.py +139 -139
- stubber/utils/typed_config_toml.py +80 -77
- stubber/variants.py +106 -106
- micropython_stubber-1.23.1.dist-info/RECORD +0 -159
- micropython_stubber-1.23.1.dist-info/entry_points.txt +0 -3
- mpflash/basicgit.py +0 -288
- {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.2.dist-info}/WHEEL +0 -0
stubber/rst/lookup.py
CHANGED
@@ -1,530 +1,533 @@
|
|
1
|
-
"""
|
2
|
-
Lookup tables for the rst documentation stubber
|
3
|
-
"""
|
4
|
-
|
5
|
-
from dataclasses import dataclass
|
6
|
-
from typing import List, Optional, Tuple
|
7
|
-
|
8
|
-
# These are shown to import
|
9
|
-
__all__ = [
|
10
|
-
"TYPING_IMPORT",
|
11
|
-
"LOOKUP_LIST",
|
12
|
-
"NONE_VERBS",
|
13
|
-
"CHILD_PARENT_CLASS",
|
14
|
-
"PARAM_FIXES",
|
15
|
-
"MODULE_GLUE",
|
16
|
-
"RST_DOC_FIXES",
|
17
|
-
"DOCSTUB_SKIP",
|
18
|
-
"U_MODULES",
|
19
|
-
]
|
20
|
-
|
21
|
-
# all possible Types needed for the stubs - exxess types should be removed later , and otherwise won't do much harm
|
22
|
-
TYPING_IMPORT: List[str] = [
|
23
|
-
"from __future__ import annotations",
|
24
|
-
"from typing import IO, Any, Callable, Coroutine, Dict, Generator, Iterator, List, NoReturn, Optional, Tuple, Union, NamedTuple, TypeVar",
|
25
|
-
"from _typeshed import Incomplete",
|
26
|
-
]
|
27
|
-
|
28
|
-
|
29
|
-
@dataclass
|
30
|
-
class Fix:
|
31
|
-
"""A fix for a parameter or return type in the documentation that is needed to render it to a valid type annotation
|
32
|
-
|
33
|
-
- from_ : the string or regex that should be fixed
|
34
|
-
- to : the improved version to replace it with
|
35
|
-
- module : filter the fix to be only applied to a specific module
|
36
|
-
- name : filter the fix to be only applied to a specific member
|
37
|
-
- is_re : the from_ string is a regular expression
|
38
|
-
"""
|
39
|
-
|
40
|
-
from_: str
|
41
|
-
"The string or regex that should be fixed"
|
42
|
-
to: str
|
43
|
-
"The improved version to replace it with"
|
44
|
-
name: Optional[str] = None
|
45
|
-
"Filter the fix to be only applied to a specific module member"
|
46
|
-
module: Optional[str] = None
|
47
|
-
"Filter the fix to be only applied to a specific module"
|
48
|
-
is_re: bool = False
|
49
|
-
"the from_ string is a regular expression"
|
50
|
-
|
51
|
-
|
52
|
-
U_MODULES = [
|
53
|
-
"array",
|
54
|
-
"binascii",
|
55
|
-
"io",
|
56
|
-
"json",
|
57
|
-
"os",
|
58
|
-
"select",
|
59
|
-
"ssl",
|
60
|
-
"struct",
|
61
|
-
"socket",
|
62
|
-
"time",
|
63
|
-
"zlib",
|
64
|
-
]
|
65
|
-
"""
|
66
|
-
List of modules that are documented with the base name only,
|
67
|
-
but can also be imported with a `u` prefix
|
68
|
-
"""
|
69
|
-
|
70
|
-
# This table is used to try to correct the errors in the documentation,
|
71
|
-
# or adapt the human readable documentation to machine readable.
|
72
|
-
# it is applied to each .rst file after loading the contents.
|
73
|
-
# also applies correction for some classes are documented as functions
|
74
|
-
|
75
|
-
RST_DOC_FIXES: List[Tuple[str, str]] = [
|
76
|
-
# remove rst highlights from docstrings
|
77
|
-
(":class: attention\n", ""),
|
78
|
-
# ------------------------------------------------------------------------------------------------
|
79
|
-
# re.rst - function and class with the same name
|
80
|
-
# done: issue https://github.com/micropython/micropython/issues/8273
|
81
|
-
# TODO: Create PR fix class Match
|
82
|
-
(".. method:: match.", ".. method:: Match."),
|
83
|
-
(" match.end", " Match.end"),
|
84
|
-
# ------------------------------------------------------------------------------------------------
|
85
|
-
# collections.rst - should be fixed in v1.19
|
86
|
-
# PR: https://github.com/micropython/micropython/pull/7976
|
87
|
-
# keep around for older docstubs
|
88
|
-
(".. function:: deque(", ".. class:: deque("),
|
89
|
-
(".. function:: OrderedDict(", ".. class:: OrderedDict("),
|
90
|
-
# ------------------------------------------------------------------------------------------------
|
91
|
-
# generator functions - WILL_NOT_FIX in the MicroPython documentation
|
92
|
-
# these are documented as functions, but return an object with the the same name as the function.
|
93
|
-
# for static type analysis this is best considered as a Class, so morph them before processing.
|
94
|
-
# uselect.rst
|
95
|
-
(".. function:: poll(", ".. class:: poll("),
|
96
|
-
# ESPNow.rst - multiple methods on a single line, split to multiline
|
97
|
-
(
|
98
|
-
".. method:: AIOESPNow._aiter__() / async AIOESPNow.__anext__()",
|
99
|
-
".. method:: AIOESPNow._aiter__()\n async AIOESPNow.__anext__()",
|
100
|
-
),
|
101
|
-
]
|
102
|
-
|
103
|
-
|
104
|
-
# docstubs generation, exclude stub generation for below stubs.
|
105
|
-
DOCSTUB_SKIP = [
|
106
|
-
"uasyncio.rst", # can create better stubs from frozen python modules.
|
107
|
-
"builtins.rst", # conflicts with static type checking , has very little information anyway
|
108
|
-
"re.rst", # regex is too complex
|
109
|
-
]
|
110
|
-
|
111
|
-
# contains return types for functions and methods that are not clearly documented.
|
112
|
-
"""
|
113
|
-
this is an list with manual overrides for function returns that could not efficiently be determined
|
114
|
-
from their docstring description
|
115
|
-
Format: a dictionary with :
|
116
|
-
- key = module.[class.]function name
|
117
|
-
- value : two-tuple with ( return type , priority )
|
118
|
-
"""
|
119
|
-
LOOKUP_LIST = {
|
120
|
-
"builtins.bytes": ("bytes", 0.95),
|
121
|
-
"builtins.from_bytes": ("int", 0.95),
|
122
|
-
"builtins.to_bytes": ("bytes", 0.95),
|
123
|
-
"bytearray_at": ("bytearray", 0.95),
|
124
|
-
"collections.namedtuple": ("stdlib_namedtuple", 0.95),
|
125
|
-
"gc.collect": ("None", 0.95),
|
126
|
-
"machine.deepsleep": ("NoReturn", 0.95),
|
127
|
-
"machine.reset_cause": ("int", 0.95),
|
128
|
-
"machine.reset": ("NoReturn", 0.95), # never returns
|
129
|
-
"machine.Signal.value": ("int", 0.95),
|
130
|
-
"machine.soft_reset": ("NoReturn", 0.95), # never returns
|
131
|
-
"machine.UART.irq": ("Incomplete", 0.95), # no IRQ type defined
|
132
|
-
"machine.UART.write": ("Union[int,None]", 0.95),
|
133
|
-
"machine.UART.readinto": ("Union[int,None]", 0.95),
|
134
|
-
"machine.UART.readline": ("Union[str,None]", 0.95),
|
135
|
-
"math.isnan": ("bool", 0.95),
|
136
|
-
"micropython.opt_level": ("Incomplete", 0.95), # Not clear in docstring
|
137
|
-
# since 1.19 const can also be string , bytes or tuple
|
138
|
-
"micropython.const": ("Const_T", 1), # const: 1 - paired with param typing
|
139
|
-
"micropython.heap_lock": ("int", 1),
|
140
|
-
"micropython.heap_unlock": ("int", 1),
|
141
|
-
"micropython.heap_locked": ("bool", 1),
|
142
|
-
"pyb.hard_reset": ("NoReturn", 0.95), # never returns
|
143
|
-
"pyb.I2C.recv": ("bytes", 0.95), # complex in docstring
|
144
|
-
"pyb.SPI.recv": ("bytes", 0.95), # complex in docstring
|
145
|
-
"
|
146
|
-
"
|
147
|
-
"
|
148
|
-
"
|
149
|
-
"
|
150
|
-
"
|
151
|
-
"
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
"
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
"stm.
|
164
|
-
#
|
165
|
-
"
|
166
|
-
|
167
|
-
"_onewire.
|
168
|
-
"_onewire.
|
169
|
-
"_onewire.
|
170
|
-
"_onewire.
|
171
|
-
"_onewire.
|
172
|
-
|
173
|
-
"
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
"
|
183
|
-
"
|
184
|
-
"
|
185
|
-
"
|
186
|
-
"
|
187
|
-
"
|
188
|
-
"
|
189
|
-
"
|
190
|
-
"
|
191
|
-
"
|
192
|
-
"
|
193
|
-
"
|
194
|
-
"
|
195
|
-
"
|
196
|
-
"
|
197
|
-
"
|
198
|
-
"
|
199
|
-
"
|
200
|
-
"
|
201
|
-
"
|
202
|
-
"
|
203
|
-
"
|
204
|
-
"
|
205
|
-
"
|
206
|
-
"
|
207
|
-
"
|
208
|
-
"
|
209
|
-
"
|
210
|
-
"
|
211
|
-
"
|
212
|
-
"
|
213
|
-
"
|
214
|
-
"
|
215
|
-
"
|
216
|
-
"
|
217
|
-
"
|
218
|
-
"
|
219
|
-
"
|
220
|
-
"
|
221
|
-
"
|
222
|
-
"
|
223
|
-
"
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
#
|
229
|
-
# - to
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
"
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
"
|
245
|
-
|
246
|
-
"
|
247
|
-
#
|
248
|
-
|
249
|
-
#
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
Fix(
|
258
|
-
Fix("
|
259
|
-
#
|
260
|
-
Fix(
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
#
|
289
|
-
#
|
290
|
-
#
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
#
|
354
|
-
# def
|
355
|
-
Fix("
|
356
|
-
#
|
357
|
-
# def
|
358
|
-
Fix("
|
359
|
-
#
|
360
|
-
#
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
#
|
370
|
-
#
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
#
|
415
|
-
#
|
416
|
-
|
417
|
-
|
418
|
-
#
|
419
|
-
# def __init__(self,
|
420
|
-
|
421
|
-
|
422
|
-
#
|
423
|
-
#
|
424
|
-
|
425
|
-
#
|
426
|
-
|
427
|
-
#
|
428
|
-
# def
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
#
|
440
|
-
# def
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
#
|
463
|
-
Fix(
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
#
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
"
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
"
|
492
|
-
|
493
|
-
|
494
|
-
"
|
495
|
-
|
496
|
-
"
|
497
|
-
"
|
498
|
-
"
|
499
|
-
#
|
500
|
-
|
501
|
-
#
|
502
|
-
#
|
503
|
-
# "
|
504
|
-
#
|
505
|
-
#
|
506
|
-
# "
|
507
|
-
#
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
511
|
-
#
|
512
|
-
#
|
513
|
-
"
|
514
|
-
"
|
515
|
-
|
516
|
-
|
517
|
-
"
|
518
|
-
"
|
519
|
-
#
|
520
|
-
"
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
1
|
+
"""
|
2
|
+
Lookup tables for the rst documentation stubber
|
3
|
+
"""
|
4
|
+
|
5
|
+
from dataclasses import dataclass
|
6
|
+
from typing import List, Optional, Tuple
|
7
|
+
|
8
|
+
# These are shown to import
|
9
|
+
__all__ = [
|
10
|
+
"TYPING_IMPORT",
|
11
|
+
"LOOKUP_LIST",
|
12
|
+
"NONE_VERBS",
|
13
|
+
"CHILD_PARENT_CLASS",
|
14
|
+
"PARAM_FIXES",
|
15
|
+
"MODULE_GLUE",
|
16
|
+
"RST_DOC_FIXES",
|
17
|
+
"DOCSTUB_SKIP",
|
18
|
+
"U_MODULES",
|
19
|
+
]
|
20
|
+
|
21
|
+
# all possible Types needed for the stubs - exxess types should be removed later , and otherwise won't do much harm
|
22
|
+
TYPING_IMPORT: List[str] = [
|
23
|
+
"from __future__ import annotations",
|
24
|
+
"from typing import IO, Any, Callable, Coroutine, Dict, Generator, Iterator, List, NoReturn, Optional, Tuple, Union, NamedTuple, TypeVar",
|
25
|
+
"from _typeshed import Incomplete",
|
26
|
+
]
|
27
|
+
|
28
|
+
|
29
|
+
@dataclass
|
30
|
+
class Fix:
|
31
|
+
"""A fix for a parameter or return type in the documentation that is needed to render it to a valid type annotation
|
32
|
+
|
33
|
+
- from_ : the string or regex that should be fixed
|
34
|
+
- to : the improved version to replace it with
|
35
|
+
- module : filter the fix to be only applied to a specific module
|
36
|
+
- name : filter the fix to be only applied to a specific member
|
37
|
+
- is_re : the from_ string is a regular expression
|
38
|
+
"""
|
39
|
+
|
40
|
+
from_: str
|
41
|
+
"The string or regex that should be fixed"
|
42
|
+
to: str
|
43
|
+
"The improved version to replace it with"
|
44
|
+
name: Optional[str] = None
|
45
|
+
"Filter the fix to be only applied to a specific module member"
|
46
|
+
module: Optional[str] = None
|
47
|
+
"Filter the fix to be only applied to a specific module"
|
48
|
+
is_re: bool = False
|
49
|
+
"the from_ string is a regular expression"
|
50
|
+
|
51
|
+
|
52
|
+
U_MODULES = [
|
53
|
+
"array",
|
54
|
+
"binascii",
|
55
|
+
"io",
|
56
|
+
"json",
|
57
|
+
"os",
|
58
|
+
"select",
|
59
|
+
"ssl",
|
60
|
+
"struct",
|
61
|
+
"socket",
|
62
|
+
"time",
|
63
|
+
"zlib",
|
64
|
+
]
|
65
|
+
"""
|
66
|
+
List of modules that are documented with the base name only,
|
67
|
+
but can also be imported with a `u` prefix
|
68
|
+
"""
|
69
|
+
|
70
|
+
# This table is used to try to correct the errors in the documentation,
|
71
|
+
# or adapt the human readable documentation to machine readable.
|
72
|
+
# it is applied to each .rst file after loading the contents.
|
73
|
+
# also applies correction for some classes are documented as functions
|
74
|
+
|
75
|
+
RST_DOC_FIXES: List[Tuple[str, str]] = [
|
76
|
+
# remove rst highlights from docstrings
|
77
|
+
(":class: attention\n", ""),
|
78
|
+
# ------------------------------------------------------------------------------------------------
|
79
|
+
# re.rst - function and class with the same name
|
80
|
+
# done: issue https://github.com/micropython/micropython/issues/8273
|
81
|
+
# TODO: Create PR fix class Match
|
82
|
+
(".. method:: match.", ".. method:: Match."),
|
83
|
+
(" match.end", " Match.end"),
|
84
|
+
# ------------------------------------------------------------------------------------------------
|
85
|
+
# collections.rst - should be fixed in v1.19
|
86
|
+
# PR: https://github.com/micropython/micropython/pull/7976
|
87
|
+
# keep around for older docstubs
|
88
|
+
(".. function:: deque(", ".. class:: deque("),
|
89
|
+
(".. function:: OrderedDict(", ".. class:: OrderedDict("),
|
90
|
+
# ------------------------------------------------------------------------------------------------
|
91
|
+
# generator functions - WILL_NOT_FIX in the MicroPython documentation
|
92
|
+
# these are documented as functions, but return an object with the the same name as the function.
|
93
|
+
# for static type analysis this is best considered as a Class, so morph them before processing.
|
94
|
+
# uselect.rst
|
95
|
+
(".. function:: poll(", ".. class:: poll("),
|
96
|
+
# ESPNow.rst - multiple methods on a single line, split to multiline
|
97
|
+
(
|
98
|
+
".. method:: AIOESPNow._aiter__() / async AIOESPNow.__anext__()",
|
99
|
+
".. method:: AIOESPNow._aiter__()\n async AIOESPNow.__anext__()",
|
100
|
+
),
|
101
|
+
]
|
102
|
+
|
103
|
+
|
104
|
+
# docstubs generation, exclude stub generation for below stubs.
|
105
|
+
DOCSTUB_SKIP = [
|
106
|
+
"uasyncio.rst", # can create better stubs from frozen python modules.
|
107
|
+
"builtins.rst", # conflicts with static type checking , has very little information anyway
|
108
|
+
"re.rst", # regex is too complex
|
109
|
+
]
|
110
|
+
|
111
|
+
# contains return types for functions and methods that are not clearly documented.
|
112
|
+
"""
|
113
|
+
this is an list with manual overrides for function returns that could not efficiently be determined
|
114
|
+
from their docstring description
|
115
|
+
Format: a dictionary with :
|
116
|
+
- key = module.[class.]function name
|
117
|
+
- value : two-tuple with ( return type , priority )
|
118
|
+
"""
|
119
|
+
LOOKUP_LIST = {
|
120
|
+
"builtins.bytes": ("bytes", 0.95),
|
121
|
+
"builtins.from_bytes": ("int", 0.95),
|
122
|
+
"builtins.to_bytes": ("bytes", 0.95),
|
123
|
+
"bytearray_at": ("bytearray", 0.95),
|
124
|
+
"collections.namedtuple": ("stdlib_namedtuple", 0.95),
|
125
|
+
"gc.collect": ("None", 0.95),
|
126
|
+
"machine.deepsleep": ("NoReturn", 0.95),
|
127
|
+
"machine.reset_cause": ("int", 0.95),
|
128
|
+
"machine.reset": ("NoReturn", 0.95), # never returns
|
129
|
+
"machine.Signal.value": ("int", 0.95),
|
130
|
+
"machine.soft_reset": ("NoReturn", 0.95), # never returns
|
131
|
+
"machine.UART.irq": ("Incomplete", 0.95), # no IRQ type defined
|
132
|
+
"machine.UART.write": ("Union[int,None]", 0.95),
|
133
|
+
"machine.UART.readinto": ("Union[int,None]", 0.95),
|
134
|
+
"machine.UART.readline": ("Union[str,None]", 0.95),
|
135
|
+
"math.isnan": ("bool", 0.95),
|
136
|
+
"micropython.opt_level": ("Incomplete", 0.95), # Not clear in docstring
|
137
|
+
# since 1.19 const can also be string , bytes or tuple
|
138
|
+
"micropython.const": ("Const_T", 1), # const: 1 - paired with param typing
|
139
|
+
"micropython.heap_lock": ("int", 1),
|
140
|
+
"micropython.heap_unlock": ("int", 1),
|
141
|
+
"micropython.heap_locked": ("bool", 1),
|
142
|
+
"pyb.hard_reset": ("NoReturn", 0.95), # never returns
|
143
|
+
"pyb.I2C.recv": ("bytes", 0.95), # complex in docstring
|
144
|
+
"pyb.SPI.recv": ("bytes", 0.95), # complex in docstring
|
145
|
+
"pyb.hid_keyboard": ("Tuple", 0.95), # ?
|
146
|
+
"pyb.hid_mouse": ("Tuple", 0.95), # plain wrong
|
147
|
+
"ubluetooth.BLE.irq": ("Any", 0.95), # never returns
|
148
|
+
"uctypes.bytearray_at": ("bytearray", 0.95),
|
149
|
+
"uctypes.bytes_at": ("bytes", 0.95),
|
150
|
+
"uio.open": ("IO", 0.95), # Open a file.
|
151
|
+
"uos.listdir": ("List[Incomplete]", 0.95),
|
152
|
+
"os.uname": ("uname_result", 0.95),
|
153
|
+
"ssl.ssl.wrap_socket": (
|
154
|
+
"IO",
|
155
|
+
0.95,
|
156
|
+
), # undocumented class ssl.SSLSocket #TODO: or wrapped-socket object ?
|
157
|
+
"ussl.ussl.wrap_socket": ("IO", 0.95), # undocumented class ssl.SSLSocket
|
158
|
+
"usys.exit": ("NoReturn", 0.95), # never returns
|
159
|
+
"utime.sleep_ms": (
|
160
|
+
"Coroutine[None, None, None]", # Micropython V1.15+ ?
|
161
|
+
0.95,
|
162
|
+
),
|
163
|
+
"stm.mem8": ("bytearray", 0.95), # Read/write 8 bits of memory.
|
164
|
+
"stm.mem16": ("bytearray", 0.95), # Read/write 16 bits of memory.
|
165
|
+
"stm.mem32": ("bytearray", 0.95), # Read/write 32 bits of memory.
|
166
|
+
# Onewire documented mostly in sourcecode
|
167
|
+
"_onewire.reset": ("bool", 0.95),
|
168
|
+
"_onewire.scan": ("List[int]", 0.95),
|
169
|
+
"_onewire.readbit": ("int", 0.95),
|
170
|
+
"_onewire.readbyte": ("int", 0.95),
|
171
|
+
"_onewire.writebyte": ("None", 0.95),
|
172
|
+
"_onewire.writebit": ("None", 0.95),
|
173
|
+
"_onewire.crc8": ("int", 0.95),
|
174
|
+
# espnow
|
175
|
+
"espnow.ESPNow.recv": ("Union[List, Tuple[None,None]]", 0.95), # list / ? tuple of bytestrings
|
176
|
+
}
|
177
|
+
|
178
|
+
|
179
|
+
# if no type has been determined, and the docstring starts with one of these verbs, then assume the return type is None
|
180
|
+
# - The starting word or words with a training space
|
181
|
+
NONE_VERBS = [
|
182
|
+
"Activate ",
|
183
|
+
"Build a ",
|
184
|
+
"Cancel ",
|
185
|
+
"Clear ",
|
186
|
+
"Close ",
|
187
|
+
"cancel ",
|
188
|
+
"Configure ",
|
189
|
+
"Connect ",
|
190
|
+
"Deactivate ",
|
191
|
+
"De-initialises ",
|
192
|
+
"Deinitialises ",
|
193
|
+
"Delay ",
|
194
|
+
"Disable ",
|
195
|
+
"Display ",
|
196
|
+
"Disconnect ",
|
197
|
+
"Draw ",
|
198
|
+
"Enable ",
|
199
|
+
"Feed the ",
|
200
|
+
"Fill the ",
|
201
|
+
"Generate ",
|
202
|
+
"Initialise the ",
|
203
|
+
"Initialize ", # US/UK spelling
|
204
|
+
"Issue a ",
|
205
|
+
"Load ",
|
206
|
+
"Modify ",
|
207
|
+
"Print ",
|
208
|
+
"Register ",
|
209
|
+
"Remove ",
|
210
|
+
"Rename ",
|
211
|
+
"Reset ",
|
212
|
+
"Resets ",
|
213
|
+
"Send ",
|
214
|
+
"Sends ",
|
215
|
+
"Set Pin ",
|
216
|
+
"Set the ",
|
217
|
+
"Sets",
|
218
|
+
"Show ",
|
219
|
+
"Stop ",
|
220
|
+
"Stops ",
|
221
|
+
"Sync ",
|
222
|
+
"Turn ",
|
223
|
+
"Wait ",
|
224
|
+
"Write ",
|
225
|
+
"Writes ",
|
226
|
+
]
|
227
|
+
|
228
|
+
# Add additional imports to generated modules
|
229
|
+
# - to allow one module te refer to another,
|
230
|
+
# - to import other supporting modules
|
231
|
+
# - to add missing abstract classes
|
232
|
+
|
233
|
+
MODULE_GLUE = {
|
234
|
+
"lcd160cr": ["from .machine import SPI"], # module returns SPI objects defined in machine
|
235
|
+
"esp32": ["from __future__ import annotations"], # Class methods return Class
|
236
|
+
"collections": [
|
237
|
+
"from queue import Queue",
|
238
|
+
"from stdlib.collections import OrderedDict as stdlib_OrderedDict, deque as stdlib_deque, namedtuple as stdlib_namedtuple",
|
239
|
+
], # dequeu is a subclass
|
240
|
+
"os": [
|
241
|
+
# "from stdlib.os import uname_result", # uname returns uname_result
|
242
|
+
"from stdlib.os import * # type: ignore", # integrate STDLIB
|
243
|
+
],
|
244
|
+
"io": ["from stdlib.io import * # type: ignore"], # integrate STDLIB
|
245
|
+
"socket": ["from stdlib.socket import * # type: ignore"], # integrate STDLIB
|
246
|
+
"ssl": ["from stdlib.ssl import * # type: ignore"], # integrate STDLIB
|
247
|
+
# const: 3 - paired with param and return typing
|
248
|
+
"micropython": ["Const_T = TypeVar('Const_T',int, float, str, bytes, Tuple) # constant"],
|
249
|
+
#
|
250
|
+
# "builtins": ["from stdlib.builtins import *"], # integrate STDLIB
|
251
|
+
# "machine": ["from network import AbstractNIC"], # NIC is an abstract class, although not defined or used as such
|
252
|
+
"espnow": ["from _espnow import ESPNowBase"], # ESPNowBase is an undocumented base class
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
PARAM_FIXES = [
|
257
|
+
Fix("\\*", "*"), # change weirdly written wildcards \* --> *
|
258
|
+
Fix(r"\**", "*"), # change weirdly written wildcards \* --> *
|
259
|
+
Fix(r"/*", "*"), # change weirdly written wildcards \* --> *
|
260
|
+
Fix(r"/)", ")"), # strange terminator in machine.USBDevice `USBDevice.active(self, [value] /)`
|
261
|
+
Fix("'param'", "param"), # loose notation in documentation
|
262
|
+
# illegal keywords
|
263
|
+
Fix(
|
264
|
+
"lambda",
|
265
|
+
"lambda_fn",
|
266
|
+
),
|
267
|
+
# method:: ADC.read_timed_multi((adcx, adcy, ...), (bufx, bufy, ...), timer)
|
268
|
+
Fix(
|
269
|
+
"(adcx, adcy, ...), (bufx, bufy, ...)",
|
270
|
+
"adcs, bufs",
|
271
|
+
),
|
272
|
+
# network.AbstractNIC
|
273
|
+
# ifconfig([(ip, subnet, gateway, dns)])
|
274
|
+
Fix(
|
275
|
+
"(ip, subnet, gateway, dns)",
|
276
|
+
"configtuple",
|
277
|
+
),
|
278
|
+
# pyb.hid((buttons, x, y, z))
|
279
|
+
Fix(
|
280
|
+
"(buttons, x, y, z)",
|
281
|
+
"hidtuple:Tuple",
|
282
|
+
),
|
283
|
+
# esp v1.15.2 .. function:: getaddrinfo((hostname, port, lambda))
|
284
|
+
Fix(
|
285
|
+
"(hostname, port, lambda)",
|
286
|
+
"tuple[str,int,Callable]",
|
287
|
+
),
|
288
|
+
# # network
|
289
|
+
# # WLANWiPy.ifconfig(if_id=0, config=['dhcp' or configtuple])
|
290
|
+
# Fix(
|
291
|
+
# "config=['dhcp' or configtuple]",
|
292
|
+
# "config: Union[str,Tuple]='dhcp'"
|
293
|
+
# ),
|
294
|
+
Fix(
|
295
|
+
"config='dhcp' or configtuple: Optional[Any]=None",
|
296
|
+
"config: Union[str,Tuple]='dhcp'",
|
297
|
+
),
|
298
|
+
# (
|
299
|
+
# "='dhcp' or configtuple: Optional[Any]=None",
|
300
|
+
# ": Union[str,Tuple]='dhcp'",
|
301
|
+
# ),
|
302
|
+
# network
|
303
|
+
# CC3K.patch_program('pgm')
|
304
|
+
Fix(
|
305
|
+
"'pgm')",
|
306
|
+
"cmd:str ,/)",
|
307
|
+
),
|
308
|
+
# network
|
309
|
+
Fix(
|
310
|
+
"block_device or path",
|
311
|
+
"block_device_or_path",
|
312
|
+
), #
|
313
|
+
# network
|
314
|
+
# ifconfig
|
315
|
+
Fix(
|
316
|
+
"(ip, subnet, gateway, dns):Optional[Any]=None",
|
317
|
+
"configtuple: Optional[Tuple]",
|
318
|
+
),
|
319
|
+
# framebuffer
|
320
|
+
# unresolvable parameter defaults # FrameBuffer: def __init__
|
321
|
+
Fix(
|
322
|
+
"stride=width",
|
323
|
+
"stride=-1",
|
324
|
+
),
|
325
|
+
# machine.Pin.__init__ constructor - Defaults assumed from the documentation.
|
326
|
+
# fixed in doc v1.18+
|
327
|
+
Fix(
|
328
|
+
", value, drive, alt",
|
329
|
+
", value=None, drive=0, alt=-1",
|
330
|
+
),
|
331
|
+
# machine.Pin.irq ...
|
332
|
+
Fix(
|
333
|
+
"trigger=(IRQ_FALLING | IRQ_RISING)",
|
334
|
+
"trigger=IRQ_FALLING ",
|
335
|
+
),
|
336
|
+
## fixes for machine.py class constants
|
337
|
+
# # BUG: This is not OK
|
338
|
+
Fix(
|
339
|
+
"pins=(SCK, MOSI, MISO)",
|
340
|
+
"pins:Optional[Tuple]",
|
341
|
+
), #
|
342
|
+
## rp2.PIO.irq
|
343
|
+
Fix(
|
344
|
+
"trigger=IRQ_SM0|IRQ_SM1|IRQ_SM2|IRQ_SM3",
|
345
|
+
"trigger=IRQ_SM0",
|
346
|
+
),
|
347
|
+
# SPI.INIT - to fix error: Non-default argument follows default argument
|
348
|
+
# ✅ fixed in doc v1.18+
|
349
|
+
Fix(
|
350
|
+
"prescaler, polarity=1",
|
351
|
+
"prescaler=1, polarity=1",
|
352
|
+
),
|
353
|
+
# network.LAN.init
|
354
|
+
# def __init__(self, id, *, phy_type=<board_default>, phy_addr=<board_default>, phy_clock=<board_default>) -> None:
|
355
|
+
Fix("=<board_default>", "=0"),
|
356
|
+
# ssl
|
357
|
+
# def wrap_socket(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=CERT_NONE, ca_certs=None, do_handshake=True) -> Any:
|
358
|
+
Fix("cert_reqs=CERT_NONE", "cert_reqs=None"),
|
359
|
+
# struct.pack & pack_into
|
360
|
+
# def pack(fmt, v1, v2, *args) -> bytes:
|
361
|
+
Fix(", v1, v2,", ", v1,"),
|
362
|
+
# esp32.RMT
|
363
|
+
# # def write_pulses(self, duration, data=True) -> Any:
|
364
|
+
# def write_pulses(self, duration, data:Union[bool,int]=True) -> Any:
|
365
|
+
Fix(
|
366
|
+
"duration, data=True",
|
367
|
+
"duration, data:Union[bool,int]=True",
|
368
|
+
),
|
369
|
+
# --------------------------------------------------------------------
|
370
|
+
# machine
|
371
|
+
# machine.PWM
|
372
|
+
# # def __init__(self, dest, *, freq, duty_u16, duty_ns) -> None: ...
|
373
|
+
# def __init__(self, dest, *, freq=0,duty=0, duty_u16=0, duty_ns=0) -> None: ...
|
374
|
+
Fix(
|
375
|
+
"dest, *, freq, duty_u16, duty_ns, invert",
|
376
|
+
"dest, *, freq=0,duty=0, duty_u16=0, duty_ns=0, invert=False",
|
377
|
+
),
|
378
|
+
# most specific fix first
|
379
|
+
Fix(
|
380
|
+
"dest, *, freq, duty_u16, duty_ns",
|
381
|
+
"dest, *, freq=0,duty=0, duty_u16=0, duty_ns=0",
|
382
|
+
),
|
383
|
+
# machine.ADC
|
384
|
+
# # def __init__(self, id, *, sample_ns, atten) -> None: ...
|
385
|
+
# def __init__(self, id, *, sample_ns:Optional[int]=0, atten:Optional[int]=ATTN_0DB) -> None: ...
|
386
|
+
Fix(
|
387
|
+
"id, *, sample_ns, atten",
|
388
|
+
"id, *, sample_ns:Optional[int]=0, atten:Optional[int]=ATTN_0DB",
|
389
|
+
),
|
390
|
+
# machine.I2C
|
391
|
+
# # def __init__(self, id, *, scl, sda, freq=400000) -> None: ...
|
392
|
+
# def __init__(self, id=-1, *, scl:Optional[Pin]=None, sda:Optional[Pin]=None, freq=400000) -> None: ...
|
393
|
+
Fix(
|
394
|
+
"id, *, scl, sda, freq=400000",
|
395
|
+
"id:Union[int,str]=-1, *, scl:Optional[Union[Pin,str]]=None, sda:Optional[Union[Pin,str]]=None, freq=400_000",
|
396
|
+
),
|
397
|
+
# network.WLAN
|
398
|
+
# def config(self, param) -> Any:
|
399
|
+
# def config(self, *args, **kwargs) -> Any:
|
400
|
+
Fix(
|
401
|
+
"param",
|
402
|
+
"*args, **kwargs",
|
403
|
+
name="WLAN.config",
|
404
|
+
),
|
405
|
+
# machine.UART
|
406
|
+
# def __init__(self, id, ...) -> None: ...
|
407
|
+
# def __init__(self, id, *args, **kwargs) -> None: ...
|
408
|
+
Fix(
|
409
|
+
"id, ...",
|
410
|
+
"id, *args, **kwargs",
|
411
|
+
name="UART.__init__",
|
412
|
+
),
|
413
|
+
# machine.SPI
|
414
|
+
# # def __init__(self, id, *args) -> None: ...
|
415
|
+
# def __init__(self, id, *args, **kwargs) -> None: ...
|
416
|
+
Fix("id, ...", "id, *args, **kwargs", name="SPI.__init__"),
|
417
|
+
# machine.Signal
|
418
|
+
# def __init__(self, pin_obj, invert=False) -> None: ...
|
419
|
+
# def __init__(self, pin_obj, *args, invert=False) -> None: ...
|
420
|
+
Fix("pin_obj, invert", "pin_obj, *args, invert", name="Signal.__init__"),
|
421
|
+
# machine.Timer
|
422
|
+
# def __init__(self, id, /, *args) -> None: ...
|
423
|
+
# def init(self,id, *, mode=PERIODIC, period=-1, callback=None) -> None: ...
|
424
|
+
Fix("id, /, ...", "id=-1, *args, **kwargs", name="Timer.__init__"),
|
425
|
+
# --------------------------------------------------------------------
|
426
|
+
# pyb
|
427
|
+
# def freq(sysclk, hclk, pclk1, pclk2) -> Tuple:
|
428
|
+
# def freq(sysclk=0, hclk=0, pclk1=0, pclk2=0) -> Tuple:
|
429
|
+
Fix("sysclk, hclk, pclk1, pclk2", "sysclk=0, hclk=0, pclk1=0, pclk2=0"),
|
430
|
+
# Timer.__init__
|
431
|
+
# def __init__(self, id, *args) -> None: ...
|
432
|
+
# def __init__(self, id, *, freq=..., prescaler=..., period=..., mode=UP, div=1, callback=None, deadtime=0) -> None:
|
433
|
+
Fix(
|
434
|
+
"id, *args",
|
435
|
+
"id, *, freq=-1, prescaler=-1, period=-1, mode=UP, div=1, callback=None, deadtime=0",
|
436
|
+
name="Timer.__init__",
|
437
|
+
),
|
438
|
+
# Timer.channel
|
439
|
+
# def channel(self, channel, mode, *args) -> Any:
|
440
|
+
# def channel(self, channel, mode, pin=None, *args) -> Any:
|
441
|
+
Fix("channel, mode, ...", "channel, mode, pin=None, *args"),
|
442
|
+
# pyb SPI
|
443
|
+
# def __init__(self, bus, *args) -> None: ...
|
444
|
+
# def __init__(self,bus, mode, baudrate=328125, *, prescaler=-1, polarity=1, phase=0, bits=8, firstbit=MSB, ti=False, crc=None) -> None:
|
445
|
+
Fix(
|
446
|
+
"bus, ...",
|
447
|
+
"bus, mode, baudrate=328125, *, prescaler=-1, polarity=1, phase=0, bits=8, firstbit=MSB, ti=False, crc=None",
|
448
|
+
),
|
449
|
+
# PYB CAN.setfiler
|
450
|
+
# def setfilter(self, bank, mode, fifo, params, *, rtr, extframe=False) -> None:
|
451
|
+
# def setfilter(self, bank, mode, fifo, params, *, rtr=..., extframe=False) -> None:
|
452
|
+
Fix(
|
453
|
+
"bank, mode, fifo, params, *, rtr, extframe=False",
|
454
|
+
"bank, mode, fifo, params, *, rtr=None, extframe=False",
|
455
|
+
),
|
456
|
+
# DOC: DocUpdate ? deal with overloads for Flash and Partition .readblock/writeblocks
|
457
|
+
Fix(
|
458
|
+
r"\s*block_num, buf, offset\s*\)",
|
459
|
+
"block_num, buf, offset: Optional[int] = 0)",
|
460
|
+
is_re=True,
|
461
|
+
),
|
462
|
+
# # This is a cleanup something that went wrong before
|
463
|
+
# Fix("**kwargs: Optional[Any]","**kwargs")
|
464
|
+
# os.mount - optional parameters
|
465
|
+
# fsobj, mount_point, *, readonly)
|
466
|
+
Fix(
|
467
|
+
"fsobj, mount_point, *, readonly)",
|
468
|
+
"fsobj, mount_point, *, readonly=False)",
|
469
|
+
),
|
470
|
+
# micropython.const
|
471
|
+
Fix("expr)", "expr:Const_T)", name="const"), # const: 3 - paired with return typing,
|
472
|
+
# ------ ESPNow.rst uses (ESP32 only) after the class / function prototype
|
473
|
+
Fix(r"\(ESP\d+\s+only\)", "", is_re=True), # ESP32 / ESP8266 Only
|
474
|
+
# espnow.ESPNow.send is missing several params
|
475
|
+
Fix(
|
476
|
+
"msg)",
|
477
|
+
"peer, msg,mac=None,sync=True)",
|
478
|
+
name="ESPNow.send",
|
479
|
+
),
|
480
|
+
Fix(
|
481
|
+
"msg)",
|
482
|
+
"peer, msg,mac=None,sync=True)",
|
483
|
+
name="ESPNow.asend",
|
484
|
+
),
|
485
|
+
]
|
486
|
+
|
487
|
+
# List of classes and their parent classes that should be added to the class definition
|
488
|
+
CHILD_PARENT_CLASS = {
|
489
|
+
# machine
|
490
|
+
# SoftSPI is defined before SPI, so baseclass is not yet available - but in a .pyi that is OK
|
491
|
+
"SoftSPI": "SPI",
|
492
|
+
"SoftI2C": "I2C",
|
493
|
+
"Switch": "Pin",
|
494
|
+
"Signal": "Pin",
|
495
|
+
# uio # unclear regarding deprecation in python 3.12
|
496
|
+
# "IOBase": "IO", # DOCME not in documentation
|
497
|
+
"TextIOWrapper": "IO", # "TextIOBase, TextIO", # based on Stdlib
|
498
|
+
"FileIO": "IO", # "RawIOBase, BinaryIO", # based on Stdlib
|
499
|
+
"StringIO": "IO", # "BufferedIOBase, BinaryIO", # based on Stdlib
|
500
|
+
"BytesIO": "IO", # "BufferedIOBase, BinaryIO", # based on Stdlib
|
501
|
+
"BufferedWriter": "IOBase", # DOCME: not in documentation # "BufferedWriter": "BufferedIOBase", # based on Stdlib
|
502
|
+
# uzlib
|
503
|
+
# "DecompIO": "IO", # https://docs.python.org/3/library/typing.html#other-concrete-types
|
504
|
+
# -------------------------------------------------------------------------------------
|
505
|
+
# network - AbstractNIC is definined in docstub network.pyi , but not actually used
|
506
|
+
# "WLAN": "AbstractNIC",
|
507
|
+
# "WLANWiPy": "AbstractNIC",
|
508
|
+
# "CC3K": "AbstractNIC",
|
509
|
+
# "WIZNET5K": "AbstractNIC",
|
510
|
+
# -------------------------------------------------------------------------------------
|
511
|
+
# uhashlib
|
512
|
+
# "md5": "hash", # BUG: hash is not defined in the MCU stubs
|
513
|
+
# "sha1": "hash",
|
514
|
+
# "sha256": "hash",
|
515
|
+
# collections
|
516
|
+
"OrderedDict": "stdlib_OrderedDict",
|
517
|
+
"namedtuple": "tuple",
|
518
|
+
"deque": "stdlib_deque",
|
519
|
+
# ESPNow
|
520
|
+
"ESPNow": "ESPNowBase,Iterator", # causes issue with mypy
|
521
|
+
"AIOESPNow": "ESPNow",
|
522
|
+
# array
|
523
|
+
"array": "List",
|
524
|
+
}
|
525
|
+
|
526
|
+
|
527
|
+
# TODO : implement the execution of this list during merge
|
528
|
+
# - this is a list of functions, classes methods and constantsn that are not detected at runtime, but are avaialble and documented
|
529
|
+
# the standard merge only adds documentation to detected functions.
|
530
|
+
FORCE_NON_DETECED = [
|
531
|
+
("btree", "Btree", ["esp32", "esp8266"]), # Is not detected runtime
|
532
|
+
("espnow", "ESPNow.peers_table", ["esp32"]), # Is not detected runtime
|
533
|
+
]
|