micropython-stubber 1.23.2__py3-none-any.whl → 1.24.0__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.
Files changed (70) hide show
  1. {micropython_stubber-1.23.2.dist-info → micropython_stubber-1.24.0.dist-info}/METADATA +30 -12
  2. {micropython_stubber-1.23.2.dist-info → micropython_stubber-1.24.0.dist-info}/RECORD +69 -66
  3. {micropython_stubber-1.23.2.dist-info → micropython_stubber-1.24.0.dist-info}/WHEEL +1 -1
  4. mpflash/README.md +2 -2
  5. mpflash/mpflash/basicgit.py +49 -9
  6. mpflash/mpflash/common.py +23 -16
  7. mpflash/mpflash/downloaded.py +10 -2
  8. mpflash/mpflash/mpboard_id/__init__.py +9 -4
  9. mpflash/mpflash/mpboard_id/add_boards.py +25 -14
  10. mpflash/mpflash/mpboard_id/board.py +2 -2
  11. mpflash/mpflash/mpboard_id/board_id.py +10 -6
  12. mpflash/mpflash/mpboard_id/board_info.zip +0 -0
  13. mpflash/mpflash/mpboard_id/store.py +8 -3
  14. mpflash/mpflash/mpremoteboard/__init__.py +13 -8
  15. mpflash/mpflash/mpremoteboard/mpy_fw_info.py +27 -16
  16. mpflash/mpflash/vendor/board_database.py +185 -0
  17. mpflash/mpflash/vendor/readme.md +10 -1
  18. mpflash/mpflash/versions.py +28 -40
  19. mpflash/poetry.lock +1605 -601
  20. mpflash/pyproject.toml +4 -3
  21. stubber/__init__.py +1 -1
  22. stubber/board/createstubs.py +51 -27
  23. stubber/board/createstubs_db.py +36 -28
  24. stubber/board/createstubs_db_min.py +171 -165
  25. stubber/board/createstubs_db_mpy.mpy +0 -0
  26. stubber/board/createstubs_mem.py +36 -28
  27. stubber/board/createstubs_mem_min.py +184 -178
  28. stubber/board/createstubs_mem_mpy.mpy +0 -0
  29. stubber/board/createstubs_min.py +102 -94
  30. stubber/board/createstubs_mpy.mpy +0 -0
  31. stubber/board/modulelist.txt +16 -0
  32. stubber/codemod/enrich.py +297 -88
  33. stubber/codemod/merge_docstub.py +250 -65
  34. stubber/codemod/test_enrich.py +87 -0
  35. stubber/codemod/visitors/typevars.py +200 -0
  36. stubber/commands/build_cmd.py +16 -3
  37. stubber/commands/clone_cmd.py +3 -3
  38. stubber/commands/config_cmd.py +4 -2
  39. stubber/commands/enrich_folder_cmd.py +33 -21
  40. stubber/commands/get_core_cmd.py +1 -2
  41. stubber/commands/get_docstubs_cmd.py +60 -6
  42. stubber/commands/get_frozen_cmd.py +15 -12
  43. stubber/commands/get_mcu_cmd.py +3 -3
  44. stubber/commands/merge_cmd.py +1 -2
  45. stubber/commands/publish_cmd.py +19 -4
  46. stubber/commands/stub_cmd.py +3 -3
  47. stubber/commands/switch_cmd.py +3 -5
  48. stubber/commands/variants_cmd.py +3 -3
  49. stubber/cst_transformer.py +52 -17
  50. stubber/freeze/common.py +27 -11
  51. stubber/freeze/freeze_manifest_2.py +8 -1
  52. stubber/freeze/get_frozen.py +4 -1
  53. stubber/merge_config.py +111 -0
  54. stubber/minify.py +1 -2
  55. stubber/publish/database.py +51 -10
  56. stubber/publish/merge_docstubs.py +33 -16
  57. stubber/publish/package.py +32 -18
  58. stubber/publish/publish.py +8 -8
  59. stubber/publish/stubpackage.py +110 -47
  60. stubber/rst/lookup.py +205 -43
  61. stubber/rst/reader.py +106 -59
  62. stubber/rst/rst_utils.py +24 -11
  63. stubber/stubber.py +1 -1
  64. stubber/stubs_from_docs.py +31 -13
  65. stubber/update_module_list.py +2 -2
  66. stubber/utils/config.py +33 -13
  67. stubber/utils/post.py +9 -6
  68. stubber/publish/missing_class_methods.py +0 -51
  69. {micropython_stubber-1.23.2.dist-info → micropython_stubber-1.24.0.dist-info}/LICENSE +0 -0
  70. {micropython_stubber-1.23.2.dist-info → micropython_stubber-1.24.0.dist-info}/entry_points.txt +0 -0
stubber/utils/post.py CHANGED
@@ -52,10 +52,13 @@ def run_autoflake(path: Path, capture_output: bool = False, process_pyi: bool =
52
52
  return -1
53
53
  log.info(f"Running autoflake on: {path}")
54
54
  # create a list of files to be formatted
55
- files: List[str] = []
56
- files.extend([str(f) for f in path.rglob("*.py")])
55
+ files: List[Path] = []
56
+ files.extend(path.rglob("*.py"))
57
57
  if process_pyi:
58
- files.extend([str(f) for f in path.rglob("*.pyi")])
58
+ files.extend(path.rglob("*.pyi"))
59
+
60
+ # do not process umodules as that would remove all imports
61
+ files = [f for f in files if not f.name.startswith("u")]
59
62
 
60
63
  # build an argument list
61
64
  autoflake_args = {
@@ -75,6 +78,6 @@ def run_autoflake(path: Path, capture_output: bool = False, process_pyi: bool =
75
78
  }
76
79
  # format the files
77
80
  exit_status = 0
78
- for name in files:
79
- log.debug(f"Running autoflake on: {name}")
80
- exit_status |= autoflake.fix_file(name, args=autoflake_args)
81
+ for f in files:
82
+ log.debug(f"Running autoflake on: {f}")
83
+ exit_status |= autoflake.fix_file(str(f), args=autoflake_args)
@@ -1,51 +0,0 @@
1
- """
2
- Add missing methods to classes in the stubs that are documented in the docstubs
3
-
4
- """
5
-
6
- from pathlib import Path
7
-
8
- import libcst as cst
9
- from mpflash.logger import log
10
-
11
- from mpflash.versions import clean_version
12
- from stubber.codemod.add_method import CallAdder, CallFinder
13
- from stubber.utils.config import CONFIG
14
- from stubber.utils.post import run_black
15
-
16
-
17
- def add_machine_pin_call(merged_path: Path, version: str):
18
- """
19
- Add the __call__ method to the machine.Pin and pyb.Pin class
20
- in all pyb and machine/umachine stubs
21
- """
22
- # TODO: this should be done in the merge_docstubs.py to avoid needing to run black twice
23
- # and to avoid having to parse the file twice
24
-
25
- # first find the __call__ method in the default stubs
26
- mod_path = (
27
- CONFIG.stub_path / f"micropython-{clean_version(version, flat=True)}-docstubs/machine.pyi"
28
- )
29
- if not mod_path.exists():
30
- log.error(f"no docstubs found for {version}")
31
- return False
32
- log.trace(f"Parsing {mod_path} for __call__ method")
33
- source = mod_path.read_text(encoding="utf-8")
34
- module = cst.parse_module(source)
35
-
36
- call_finder = CallFinder()
37
- module.visit(call_finder)
38
-
39
- if call_finder.call_meth is None:
40
- log.error("no __call__ method found")
41
- return False
42
-
43
- # then use the CallAdder to add the __call__ method to all machine and pyb stubs
44
- mod_paths = [f for f in merged_path.rglob("*.*") if f.stem in {"machine", "umachine", "pyb"}]
45
- for mod_path in mod_paths:
46
- source = mod_path.read_text(encoding="utf-8")
47
- machine_module = cst.parse_module(source)
48
- new_module = machine_module.visit(CallAdder(call_finder.call_meth))
49
- mod_path.write_text(new_module.code, encoding="utf-8")
50
- run_black(mod_path)
51
- return True