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
mpflash/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mpflash"
3
- version = "1.0.2"
3
+ version = "1.24.6"
4
4
  description = "Flash and download tool for MicroPython firmwares"
5
5
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
6
6
  license = "MIT"
@@ -18,6 +18,7 @@ classifiers = [
18
18
  mpflash = "mpflash.cli_main:mpflash"
19
19
 
20
20
  [tool.poetry.dependencies]
21
+ python = ">=3.9,<4.0"
21
22
  beautifulsoup4 = "^4.12.3"
22
23
  bincopy = "^20.0.0"
23
24
  blkinfo = "^0.2.0"
@@ -29,16 +30,16 @@ jsons = "^1.6.3"
29
30
  libusb = { version = "^1.0.27", platform = "win32" }
30
31
  loguru = "^0.7.2"
31
32
  mpremote = "^1.22.0"
32
- packaging = "23.2"
33
+ packaging = "^24.2"
33
34
  platformdirs = "^4.2.0"
34
35
  psutil = "^5.9.8"
35
36
  pygithub = "^2.1.1"
36
- python = ">=3.8.1,<4.0"
37
37
  pyusb = "^1.2.1"
38
38
  requests = "^2.31.0"
39
39
  rich-click = "^1.8.1"
40
40
  tenacity = "8.2.3"
41
41
  cache-to-disk = "^2.0.0"
42
+ poetry = "^2.0.1"
42
43
 
43
44
 
44
45
  [tool.poetry.group.dev]
stubber/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """get the version"""
2
2
 
3
- __version__ = "1.23.2"
3
+ __version__ = "1.24.0"
@@ -24,8 +24,7 @@ try:
24
24
  except ImportError:
25
25
  from ucollections import OrderedDict # type: ignore
26
26
 
27
- __version__ = "v1.23.2"
28
- version_str = __version__.rsplit(".", 1)[0]
27
+ __version__ = "v1.24.0"
29
28
  ENOENT = 2
30
29
  _MAX_CLASS_LEVEL = 2 # Max class nesting
31
30
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
@@ -33,7 +32,7 @@ LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
33
32
 
34
33
  # our own logging module to avoid dependency on and interfering with logging module
35
34
  class logging:
36
- # DEBUG = 10
35
+ DEBUG = 10
37
36
  INFO = 20
38
37
  WARNING = 30
39
38
  ERROR = 40
@@ -48,9 +47,9 @@ class logging:
48
47
  def basicConfig(cls, level):
49
48
  cls.level = level
50
49
 
51
- # def debug(self, msg):
52
- # if self.level <= logging.DEBUG:
53
- # self.prnt("DEBUG :", msg)
50
+ def debug(self, msg):
51
+ if self.level <= logging.DEBUG:
52
+ self.prnt("DEBUG :", msg)
54
53
 
55
54
  def info(self, msg):
56
55
  if self.level <= logging.INFO:
@@ -232,11 +231,12 @@ class Stubber:
232
231
  return False
233
232
 
234
233
  # Start a new file
234
+ # log.debug("Create file: {}".format(file_name))
235
235
  ensure_folder(file_name)
236
236
  with open(file_name, "w") as fp:
237
237
  info_ = str(self.info).replace("OrderedDict(", "").replace("})", "}")
238
238
  s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(
239
- module_name, self._fwid, info_, version_str
239
+ module_name, self._fwid, info_, __version__
240
240
  )
241
241
  fp.write(s)
242
242
  fp.write(
@@ -355,8 +355,10 @@ class Stubber:
355
355
 
356
356
  if t in ("str", "int", "float", "bool", "bytearray", "bytes"):
357
357
  # known type: use actual value
358
- # s = "{0}{1} = {2} # type: {3}\n".format(indent, item_name, item_repr, t)
359
- s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t)
358
+ if item_name.upper() == item_name: # ALL_CAPS --> Final
359
+ s = "{0}{1}: Final[{3}] = {2}\n".format(indent, item_name, item_repr, t)
360
+ else:
361
+ s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t)
360
362
  elif t in ("dict", "list", "tuple"):
361
363
  # dict, list , tuple: use empty value
362
364
  ev = {"dict": "{}", "list": "[]", "tuple": "()"}
@@ -444,7 +446,7 @@ class Stubber:
444
446
  f.write("{")
445
447
  f.write(dumps({"firmware": self.info})[1:-1])
446
448
  f.write(",\n")
447
- f.write(dumps({"stubber": {"version": version_str}, "stubtype": "firmware"})[1:-1])
449
+ f.write(dumps({"stubber": {"version": __version__}, "stubtype": "firmware"})[1:-1])
448
450
  f.write(",\n")
449
451
  f.write('"modules" :[\n')
450
452
 
@@ -495,6 +497,7 @@ def ensure_folder(path: str):
495
497
  # folder does not exist
496
498
  if e.args[0] == ENOENT:
497
499
  try:
500
+ log.debug("Create folder {}".format(p))
498
501
  os.mkdir(p)
499
502
  except OSError as e2:
500
503
  log.error("failed to create folder {}".format(p))
@@ -505,7 +508,7 @@ def ensure_folder(path: str):
505
508
 
506
509
  def _build(s):
507
510
  # extract build from sys.version or os.uname().version if available
508
- # sys.version: 'MicroPython v1.23.2-preview.6.g3d0b6276f'
511
+ # sys.version: 'MicroPython v1.24.0-preview.6.g3d0b6276f'
509
512
  # sys.implementation.version: 'v1.13-103-gb137d064e'
510
513
  if not s:
511
514
  return ""
@@ -613,29 +616,33 @@ def _info(): # type:() -> dict[str, str]
613
616
  info["version"]
614
617
  and info["version"].endswith(".0")
615
618
  and info["version"]
616
- >= "1.10.0" # versions from 1.10.0 to 1.23.2 do not have a micro .0
619
+ >= "1.10.0" # versions from 1.10.0 to 1.24.0 do not have a micro .0
617
620
  and info["version"] <= "1.19.9"
618
621
  ):
619
- # versions from 1.10.0 to 1.23.2 do not have a micro .0
622
+ # versions from 1.10.0 to 1.24.0 do not have a micro .0
620
623
  info["version"] = info["version"][:-2]
621
624
 
622
625
  # spell-checker: disable
623
626
  if "mpy" in info and info["mpy"]: # mpy on some v1.11+ builds
624
627
  sys_mpy = int(info["mpy"])
625
628
  # .mpy architecture
626
- arch = [
627
- None,
628
- "x86",
629
- "x64",
630
- "armv6",
631
- "armv6m",
632
- "armv7m",
633
- "armv7em",
634
- "armv7emsp",
635
- "armv7emdp",
636
- "xtensa",
637
- "xtensawin",
638
- ][sys_mpy >> 10]
629
+ try:
630
+ arch = [
631
+ None,
632
+ "x86",
633
+ "x64",
634
+ "armv6",
635
+ "armv6m",
636
+ "armv7m",
637
+ "armv7em",
638
+ "armv7emsp",
639
+ "armv7emdp",
640
+ "xtensa",
641
+ "xtensawin",
642
+ "rv32imc",
643
+ ][sys_mpy >> 10]
644
+ except IndexError:
645
+ arch = "unknown"
639
646
  if arch:
640
647
  info["arch"] = arch
641
648
  # .mpy version.minor
@@ -675,7 +682,7 @@ def get_root() -> str: # sourcery skip: use-assigned-variable
675
682
  # unix port
676
683
  c = "."
677
684
  r = c
678
- for r in [c, "/sd", "/flash", "/", "."]:
685
+ for r in ["/remote", "/sd", "/flash", "/", c, "."]:
679
686
  try:
680
687
  _ = os.stat(r)
681
688
  break
@@ -819,6 +826,8 @@ def main():
819
826
  "breakout_trackball",
820
827
  "breakout_vl53l5cx",
821
828
  "btree",
829
+ "builtins",
830
+ "cc3200",
822
831
  "cmath",
823
832
  "collections",
824
833
  "crypto",
@@ -829,10 +838,12 @@ def main():
829
838
  "display",
830
839
  "display_driver_utils",
831
840
  "ds18x20",
841
+ "embed",
832
842
  "encoder",
833
843
  "errno",
834
844
  "esp",
835
845
  "esp32",
846
+ "esp8266",
836
847
  "espidf",
837
848
  "espnow",
838
849
  "ffi",
@@ -867,11 +878,13 @@ def main():
867
878
  "lvgl",
868
879
  "lwip",
869
880
  "machine",
881
+ "marshal",
870
882
  "math",
871
883
  "microWebSocket",
872
884
  "microWebSrv",
873
885
  "microWebTemplate",
874
886
  "micropython",
887
+ "mimxrt",
875
888
  "mip",
876
889
  "mip/__init__",
877
890
  "mip/__main__",
@@ -880,11 +893,13 @@ def main():
880
893
  "mpu9250",
881
894
  "neopixel",
882
895
  "network",
896
+ "nrf",
883
897
  "ntptime",
884
898
  "onewire",
885
899
  "openamp",
886
900
  "os",
887
901
  "pcf85063a",
902
+ "pic16bit",
888
903
  "picoexplorer",
889
904
  "picographics",
890
905
  "picokeypad",
@@ -896,12 +911,16 @@ def main():
896
911
  "pimoroni_i2c",
897
912
  "plasma",
898
913
  "platform",
914
+ "powerpc",
899
915
  "pyb",
900
916
  "pycom",
901
917
  "pye",
918
+ "qemu",
902
919
  "qrcode",
903
920
  "queue",
904
921
  "random",
922
+ "renesas",
923
+ "renesas-ra",
905
924
  "requests",
906
925
  "requests/__init__",
907
926
  "rp2",
@@ -914,6 +933,7 @@ def main():
914
933
  "ssh",
915
934
  "ssl",
916
935
  "stm",
936
+ "stm32",
917
937
  "struct",
918
938
  "sys",
919
939
  "termios",
@@ -954,6 +974,7 @@ def main():
954
974
  "umqtt/__init__",
955
975
  "umqtt/robust",
956
976
  "umqtt/simple",
977
+ "unix",
957
978
  "uos",
958
979
  "uplatform",
959
980
  "uqueue",
@@ -979,8 +1000,10 @@ def main():
979
1000
  "uzlib",
980
1001
  "version",
981
1002
  "vfs",
1003
+ "webassembly",
982
1004
  "websocket",
983
1005
  "websocket_helper",
1006
+ "windows",
984
1007
  "wipy",
985
1008
  "writer",
986
1009
  "xpt2046",
@@ -996,6 +1019,7 @@ def main():
996
1019
 
997
1020
  if __name__ == "__main__" or is_micropython():
998
1021
  if not file_exists("no_auto_stubber.txt"):
1022
+ print(f"createstubs.py: {__version__}")
999
1023
  try:
1000
1024
  gc.threshold(4 * 1024) # type: ignore
1001
1025
  gc.enable()
@@ -18,7 +18,7 @@ Create stubs for (all) modules on a MicroPython board.
18
18
  - cross compilation, using mpy-cross, to avoid the compilation step on the micropython device
19
19
 
20
20
 
21
- This variant was generated from createstubs.py by micropython-stubber v1.23.2
21
+ This variant was generated from createstubs.py by micropython-stubber v1.24.0
22
22
  """
23
23
 
24
24
  # Copyright (c) 2019-2024 Jos Verlinde
@@ -43,8 +43,7 @@ try:
43
43
  except ImportError:
44
44
  from ucollections import OrderedDict # type: ignore
45
45
 
46
- __version__ = "v1.23.2"
47
- version_str = __version__.rsplit(".", 1)[0]
46
+ __version__ = "v1.24.0"
48
47
  ENOENT = 2
49
48
  _MAX_CLASS_LEVEL = 2 # Max class nesting
50
49
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
@@ -52,7 +51,7 @@ LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
52
51
 
53
52
  # our own logging module to avoid dependency on and interfering with logging module
54
53
  class logging:
55
- # DEBUG = 10
54
+ DEBUG = 10
56
55
  INFO = 20
57
56
  WARNING = 30
58
57
  ERROR = 40
@@ -67,9 +66,9 @@ class logging:
67
66
  def basicConfig(cls, level):
68
67
  cls.level = level
69
68
 
70
- # def debug(self, msg):
71
- # if self.level <= logging.DEBUG:
72
- # self.prnt("DEBUG :", msg)
69
+ def debug(self, msg):
70
+ if self.level <= logging.DEBUG:
71
+ self.prnt("DEBUG :", msg)
73
72
 
74
73
  def info(self, msg):
75
74
  if self.level <= logging.INFO:
@@ -245,10 +244,11 @@ class Stubber:
245
244
  return False
246
245
 
247
246
  # Start a new file
247
+ # log.debug("Create file: {}".format(file_name))
248
248
  ensure_folder(file_name)
249
249
  with open(file_name, "w") as fp:
250
250
  info_ = str(self.info).replace("OrderedDict(", "").replace("})", "}")
251
- s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(module_name, self._fwid, info_, version_str)
251
+ s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(module_name, self._fwid, info_, __version__)
252
252
  fp.write(s)
253
253
  fp.write("from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n")
254
254
  self.write_object_stub(fp, new_module, module_name, "")
@@ -358,8 +358,10 @@ class Stubber:
358
358
 
359
359
  if t in ("str", "int", "float", "bool", "bytearray", "bytes"):
360
360
  # known type: use actual value
361
- # s = "{0}{1} = {2} # type: {3}\n".format(indent, item_name, item_repr, t)
362
- s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t)
361
+ if item_name.upper() == item_name: # ALL_CAPS --> Final
362
+ s = "{0}{1}: Final[{3}] = {2}\n".format(indent, item_name, item_repr, t)
363
+ else:
364
+ s = "{0}{1}: {3} = {2}\n".format(indent, item_name, item_repr, t)
363
365
  elif t in ("dict", "list", "tuple"):
364
366
  # dict, list , tuple: use empty value
365
367
  ev = {"dict": "{}", "list": "[]", "tuple": "()"}
@@ -443,7 +445,7 @@ class Stubber:
443
445
  f.write("{")
444
446
  f.write(dumps({"firmware": self.info})[1:-1])
445
447
  f.write(",\n")
446
- f.write(dumps({"stubber": {"version": version_str}, "stubtype": "firmware"})[1:-1])
448
+ f.write(dumps({"stubber": {"version": __version__}, "stubtype": "firmware"})[1:-1])
447
449
  f.write(",\n")
448
450
  f.write('"modules" :[\n')
449
451
 
@@ -492,6 +494,7 @@ def ensure_folder(path: str):
492
494
  # folder does not exist
493
495
  if e.args[0] == ENOENT:
494
496
  try:
497
+ log.debug("Create folder {}".format(p))
495
498
  os.mkdir(p)
496
499
  except OSError as e2:
497
500
  log.error("failed to create folder {}".format(p))
@@ -502,7 +505,7 @@ def ensure_folder(path: str):
502
505
 
503
506
  def _build(s):
504
507
  # extract build from sys.version or os.uname().version if available
505
- # sys.version: 'MicroPython v1.23.2-preview.6.g3d0b6276f'
508
+ # sys.version: 'MicroPython v1.24.0-preview.6.g3d0b6276f'
506
509
  # sys.implementation.version: 'v1.13-103-gb137d064e'
507
510
  if not s:
508
511
  return ""
@@ -607,29 +610,33 @@ def _info(): # type:() -> dict[str, str]
607
610
  if (
608
611
  info["version"]
609
612
  and info["version"].endswith(".0")
610
- and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.23.2 do not have a micro .0
613
+ and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.24.0 do not have a micro .0
611
614
  and info["version"] <= "1.19.9"
612
615
  ):
613
- # versions from 1.10.0 to 1.23.2 do not have a micro .0
616
+ # versions from 1.10.0 to 1.24.0 do not have a micro .0
614
617
  info["version"] = info["version"][:-2]
615
618
 
616
619
  # spell-checker: disable
617
620
  if "mpy" in info and info["mpy"]: # mpy on some v1.11+ builds
618
621
  sys_mpy = int(info["mpy"])
619
622
  # .mpy architecture
620
- arch = [
621
- None,
622
- "x86",
623
- "x64",
624
- "armv6",
625
- "armv6m",
626
- "armv7m",
627
- "armv7em",
628
- "armv7emsp",
629
- "armv7emdp",
630
- "xtensa",
631
- "xtensawin",
632
- ][sys_mpy >> 10]
623
+ try:
624
+ arch = [
625
+ None,
626
+ "x86",
627
+ "x64",
628
+ "armv6",
629
+ "armv6m",
630
+ "armv7m",
631
+ "armv7em",
632
+ "armv7emsp",
633
+ "armv7emdp",
634
+ "xtensa",
635
+ "xtensawin",
636
+ "rv32imc",
637
+ ][sys_mpy >> 10]
638
+ except IndexError:
639
+ arch = "unknown"
633
640
  if arch:
634
641
  info["arch"] = arch
635
642
  # .mpy version.minor
@@ -669,7 +676,7 @@ def get_root() -> str: # sourcery skip: use-assigned-variable
669
676
  # unix port
670
677
  c = "."
671
678
  r = c
672
- for r in [c, "/sd", "/flash", "/", "."]:
679
+ for r in ["/remote", "/sd", "/flash", "/", c, "."]:
673
680
  try:
674
681
  _ = os.stat(r)
675
682
  break
@@ -818,6 +825,7 @@ def main():
818
825
 
819
826
  if __name__ == "__main__" or is_micropython():
820
827
  if not file_exists("no_auto_stubber.txt"):
828
+ print(f"createstubs.py: {__version__}")
821
829
  try:
822
830
  gc.threshold(4 * 1024) # type: ignore
823
831
  gc.enable()