|
1 | 1 | """
|
2 |
| -Update the micropython-stlib-stubs |
3 |
| -- based on typeshed |
| 2 | +Update the micropython-stlib-stubs |
| 3 | +- based on typeshed |
4 | 4 | - merged with (some) micropython documentation.`
|
5 | 5 |
|
6 | 6 | """
|
|
16 | 16 | import rich_click as click
|
17 | 17 | from loguru import logger as log
|
18 | 18 | from mpflash.versions import clean_version, get_stable_mp_version
|
19 |
| -from stubber.codemod.enrich import enrich_folder, enrich_file |
| 19 | +from stubber.codemod.enrich import enrich_file, enrich_folder |
20 | 20 | from stubber.modcat import STDLIB_ONLY_MODULES
|
21 | 21 | from stubber.utils import do_post_processing
|
22 | 22 | from stubber.utils.config import readconfig
|
|
75 | 75 | "json/decoder.pyi",
|
76 | 76 | "json/encoder.pyi",
|
77 | 77 | "json/tool.pyi",
|
78 |
| - |
79 | 78 | ]
|
80 | 79 |
|
81 | 80 |
|
|
137 | 136 | # this is for things such as function or classdefs that extend beyond a single line
|
138 | 137 | CHANGE_LINES = [
|
139 | 138 | ("ssl", [("def create_default_context", "def __mpy_has_no_create_default_context")]),
|
140 |
| - ("sys", [ |
141 |
| - ("def atexit(", "def __mpy_has_no_atexit("), |
142 |
| - ("implementation: _implementation", "implementation: _mp_implementation"), |
143 |
| - ]), |
| 139 | + ( |
| 140 | + "sys", |
| 141 | + [ |
| 142 | + ("def atexit(", "def __mpy_has_no_atexit("), |
| 143 | + ( |
| 144 | + "implementation: _implementation", |
| 145 | + "implementation: _mp_implementation", |
| 146 | + ), # TODO : simplify by merging attribute types. |
| 147 | + ], |
| 148 | + ), |
144 | 149 | ]
|
145 | 150 |
|
146 | 151 |
|
@@ -283,9 +288,12 @@ def change_lines(folder: Path):
|
283 | 288 | n += 1
|
284 | 289 | f.write(line)
|
285 | 290 |
|
286 |
| -def update_typing_pyi(dist_stdlib_path: Path, ): |
| 291 | + |
| 292 | +def update_typing_pyi( |
| 293 | + dist_stdlib_path: Path, |
| 294 | +): |
287 | 295 | """
|
288 |
| - patch updates into typing.pyi |
| 296 | + patch updates into typing.pyi |
289 | 297 | - allow IO.write(bytes) overload
|
290 | 298 | """
|
291 | 299 | tsk = enrich_file(
|
@@ -369,8 +377,8 @@ def merge_docstubs_into_stdlib(
|
369 | 377 | Boost("io"),
|
370 | 378 | Boost("array"),
|
371 | 379 | # evaluating
|
372 |
| - # Boost("tls"), # -- MicroPython only - does not exists in stdlib |
373 |
| - Boost("socket"), # not available in all boards ... |
| 380 | + # Boost("tls"), # -- MicroPython only - does not exists in stdlib |
| 381 | + Boost("socket"), # not available in all boards ... |
374 | 382 | Boost("json"),
|
375 | 383 | Boost("struct"),
|
376 | 384 | Boost("builtins"),
|
@@ -533,7 +541,7 @@ def update(
|
533 | 541 | # TODO
|
534 | 542 | # clone typeshed if needed and switch to the correct hash
|
535 | 543 | print("in the repos folder run:")
|
536 |
| - print("git clone https://github.com/python/typeshed.git\n" "cd typeshed\n" "git checkout <commit-hash>") |
| 544 | + print("git clone https://github.com/python/typeshed.git\ncd typeshed\ngit checkout <commit-hash>") |
537 | 545 | log.warning("Not implemented yet")
|
538 | 546 |
|
539 | 547 | if typeshed:
|
@@ -579,5 +587,4 @@ def update(
|
579 | 587 |
|
580 | 588 |
|
581 | 589 | if __name__ == "__main__":
|
582 |
| - |
583 | 590 | update()
|
0 commit comments