micropython-stubber 1.25.0.post2__tar.gz → 1.25.1rc6__tar.gz

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 (109) hide show
  1. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/PKG-INFO +3 -3
  2. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/pyproject.toml +3 -3
  3. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/visitors/type_helpers.py +16 -7
  4. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/minify.py +30 -9
  5. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/package.py +12 -3
  6. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/stubpackage.py +7 -12
  7. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/lookup.py +6 -0
  8. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/reader.py +15 -6
  9. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/stubs_from_docs.py +28 -15
  10. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/LICENSE +0 -0
  11. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/readme.md +0 -0
  12. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/__init__.py +0 -0
  13. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/board_info.csv +0 -0
  14. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/boot.py +0 -0
  15. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs.py +0 -0
  16. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_db.py +0 -0
  17. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_db_min.py +0 -0
  18. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_db_mpy.mpy +0 -0
  19. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_lvgl.py +0 -0
  20. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_lvgl_min.py +0 -0
  21. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_lvgl_mpy.mpy +0 -0
  22. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_mem.py +0 -0
  23. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_mem_min.py +0 -0
  24. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_mem_mpy.mpy +0 -0
  25. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_min.py +0 -0
  26. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/createstubs_mpy.mpy +0 -0
  27. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/fw_info.py +0 -0
  28. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/info.py +0 -0
  29. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/main.py +0 -0
  30. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/modulelist.txt +0 -0
  31. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/pkg_full.json +0 -0
  32. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/pkg_minified.json +0 -0
  33. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/pkg_mpy.json +0 -0
  34. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/board/pyrightconfig.json +0 -0
  35. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/bulk/mcu_stubber.py +0 -0
  36. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/__init__.py +0 -0
  37. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/_partials/__init__.py +0 -0
  38. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/_partials/db_main.py +0 -0
  39. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/_partials/lvgl_main.py +0 -0
  40. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/_partials/modules_reader.py +0 -0
  41. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/add_comment.py +0 -0
  42. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/add_method.py +0 -0
  43. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/board.py +0 -0
  44. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/enrich.py +0 -0
  45. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/merge_docstub.py +0 -0
  46. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/modify_list.py +0 -0
  47. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/codemod/utils.py +0 -0
  48. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/__init__.py +0 -0
  49. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/build_cmd.py +0 -0
  50. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/cli.py +0 -0
  51. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/clone_cmd.py +0 -0
  52. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/config_cmd.py +0 -0
  53. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/enrich_folder_cmd.py +0 -0
  54. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/get_core_cmd.py +0 -0
  55. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/get_docstubs_cmd.py +0 -0
  56. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/get_frozen_cmd.py +0 -0
  57. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/get_mcu_cmd.py +0 -0
  58. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/merge_cmd.py +0 -0
  59. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/publish_cmd.py +0 -0
  60. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/stub_cmd.py +0 -0
  61. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/switch_cmd.py +0 -0
  62. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/commands/variants_cmd.py +0 -0
  63. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/data/board_info.csv +0 -0
  64. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/data/board_info.json +0 -0
  65. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/data/micropython_tags.csv +0 -0
  66. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/data/requirements-core-micropython.txt +0 -0
  67. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/data/requirements-core-pycopy.txt +0 -0
  68. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/downloader.py +0 -0
  69. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/freeze/__init__.py +0 -0
  70. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/freeze/common.py +0 -0
  71. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/freeze/freeze_folder.py +0 -0
  72. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/freeze/freeze_manifest_2.py +0 -0
  73. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/freeze/get_frozen.py +0 -0
  74. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/get_cpython.py +0 -0
  75. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/get_lobo.py +0 -0
  76. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/merge_config.py +0 -0
  77. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/modcat.py +0 -0
  78. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/__init__.py +0 -0
  79. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/bump.py +0 -0
  80. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/candidates.py +0 -0
  81. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/database.py +0 -0
  82. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/defaults.py +0 -0
  83. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/enums.py +0 -0
  84. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/helpers.py +0 -0
  85. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/merge_docstubs.py +0 -0
  86. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/pathnames.py +0 -0
  87. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/publish.py +0 -0
  88. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/publish/pypi.py +0 -0
  89. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/__init__.py +0 -0
  90. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/classsort.py +0 -0
  91. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/output_dict.py +0 -0
  92. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/report_return.py +0 -0
  93. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/rst/rst_utils.py +0 -0
  94. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/stubber.py +0 -0
  95. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/tools/__init__.py +0 -0
  96. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/tools/manifestfile.py +0 -0
  97. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/tools/readme.md +0 -0
  98. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/typing_collector.py +0 -0
  99. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/update_fallback.py +0 -0
  100. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/update_module_list.py +0 -0
  101. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/__init__.py +0 -0
  102. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/config.py +0 -0
  103. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/makeversionhdr.py +0 -0
  104. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/manifest.py +0 -0
  105. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/post.py +0 -0
  106. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/repos.py +0 -0
  107. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/stubmaker.py +0 -0
  108. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/utils/typed_config_toml.py +0 -0
  109. {micropython_stubber-1.25.0.post2 → micropython_stubber-1.25.1rc6}/src/stubber/variants.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: micropython-stubber
3
- Version: 1.25.0.post2
3
+ Version: 1.25.1rc6
4
4
  Summary: Tooling to create and maintain stubs for MicroPython
5
5
  License: MIT
6
6
  Keywords: MicroPython,stubs,vscode,pyright,linting,static type check
@@ -25,12 +25,12 @@ Requires-Dist: executing (>=2.0.1,<3.0.0)
25
25
  Requires-Dist: importlib-metadata (>=1,<9) ; python_version < "3.8"
26
26
  Requires-Dist: libcst (>=1.1.0,<2.0.0)
27
27
  Requires-Dist: loguru (>=0.6,<0.8)
28
- Requires-Dist: mpflash (>=1.25.0)
28
+ Requires-Dist: mpflash (==1.25.0.rc3)
29
29
  Requires-Dist: mpremote (>=1.25.0)
30
+ Requires-Dist: mpy-cross (>=1.25.0.post2,<2.0.0)
30
31
  Requires-Dist: mypy (>=1.10)
31
32
  Requires-Dist: mypy-gitlab-code-quality (>=1.1.0,<2.0.0)
32
33
  Requires-Dist: packaging (>=24.2,<25.0)
33
- Requires-Dist: pipx (>=1.1.0,<2.0.0)
34
34
  Requires-Dist: poetry (>=2.0.1,<3.0.0)
35
35
  Requires-Dist: pydeps (==3.0.1)
36
36
  Requires-Dist: pygithub (>=2.1.1,<3.0.0)
@@ -8,7 +8,7 @@ repo-path = "./repos"
8
8
 
9
9
  [tool.poetry]
10
10
  name = "micropython-stubber"
11
- version = "1.25.0.post2"
11
+ version = "1.25.1.rc6"
12
12
  description = "Tooling to create and maintain stubs for MicroPython"
13
13
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
14
14
  license = "MIT"
@@ -50,7 +50,7 @@ mpremote = "mpremote.main:main"
50
50
  python = ">=3.9.2,<4.0"
51
51
  python-minifier = { version = "^2.7.0", python = "<3.14" }
52
52
  requests = "^2.32.3"
53
- mpflash = ">=1.25.0"
53
+ mpflash = "==1.25.0.rc3"
54
54
  mpremote = ">=1.25.0"
55
55
  # others
56
56
  autoflake = ">=1.7,<3.0"
@@ -63,7 +63,6 @@ importlib-metadata = { version = ">=1,<9", python = "<3.8" }
63
63
  loguru = ">=0.6,<0.8"
64
64
  mypy-gitlab-code-quality = "^1.1.0"
65
65
  packaging = "^24.2"
66
- pipx = "^1.1.0"
67
66
  pygithub = "^2.1.1"
68
67
  pyserial = ">=3.5"
69
68
  pypi-simple = "^1.0.0"
@@ -77,6 +76,7 @@ poetry = "^2.0.1"
77
76
  pydeps = "3.0.1"
78
77
  pyright = ">=1.1.341"
79
78
  mypy = ">=1.10"
79
+ mpy-cross = "^1.25.0.post2"
80
80
 
81
81
 
82
82
  [tool.poetry.group.docs]
@@ -47,13 +47,22 @@ def is_CONSTANT(statement):
47
47
  AnnAssign- FOO:bool = ...
48
48
  """
49
49
 
50
- if m.matches(statement, m.SimpleStatementLine()):
51
- statement = statement.body[0]
52
- if m.matches(statement, m.Assign()):
53
- if len(statement.targets) != 1:
54
- return False
55
- if statement.targets[0].target.value.isupper():
56
- return True
50
+ try:
51
+ if m.matches(statement, m.SimpleStatementLine()):
52
+ statement = statement.body[0]
53
+ if m.matches(statement, m.Assign()):
54
+ if len(statement.targets) != 1:
55
+ return False
56
+ if m.matches(statement.targets[0], m.Name()):
57
+ if statement.targets[0].target.value.isupper():
58
+ return True
59
+ elif m.matches(statement.targets[0], m.AssignTarget()):
60
+ if m.matches(statement.targets[0].target, m.Name()):
61
+ if statement.targets[0].children[0].value.isupper():
62
+ return True
63
+ except Exception as e:
64
+ log.debug(f"Error in is_CONSTANT: {e}")
65
+ return False
57
66
  return False
58
67
 
59
68
 
@@ -5,6 +5,7 @@ Minimizes and cross-compiles a MicroPyton file.
5
5
 
6
6
  import itertools
7
7
  import subprocess
8
+ import sys
8
9
  import tempfile
9
10
  from contextlib import ExitStack
10
11
  from io import BytesIO, IOBase, StringIO, TextIOWrapper
@@ -18,6 +19,8 @@ except ImportError:
18
19
 
19
20
  from mpflash.logger import log
20
21
  from mpflash.versions import SET_PREVIEW, V_PREVIEW
22
+ import shutil
23
+ import os
21
24
 
22
25
  # Type Aliases for minify
23
26
  StubSource = Union[Path, str, StringIO, TextIOWrapper]
@@ -369,10 +372,10 @@ def cross_compile(
369
372
  else:
370
373
  # target must be a Path object
371
374
  _target = get_temp_file(suffix=".mpy")
372
- result = pipx_mpy_cross(version, source_file, _target)
375
+ result = run_mpy_cross(version, source_file, _target)
373
376
  if result.stderr and "No matching distribution found for mpy-cross~=" in result.stderr:
374
377
  log.warning(f"mpy-cross~={version} not found, using most current version.")
375
- result = pipx_mpy_cross(V_PREVIEW, source_file, _target)
378
+ result = run_mpy_cross(V_PREVIEW, source_file, _target)
376
379
 
377
380
  if result.returncode == 0:
378
381
  log.debug(f"mpy-cross compiled to : {_target.name}")
@@ -388,18 +391,36 @@ def cross_compile(
388
391
  return result.returncode
389
392
 
390
393
 
391
- def pipx_mpy_cross(version: str, source_file, _target):
392
- """Run mpy-cross using pipx"""
393
-
394
+ def locate_mpy_cross():
395
+ """Locate the path of the mpy-cross commandline tool in the active environment"""
396
+ try:
397
+ # Check if it's available as a command in PATH
398
+ mpy_cross_path = shutil.which("mpy-cross")
399
+ if mpy_cross_path:
400
+ log.info(f"Found mpy-cross executable in PATH: {mpy_cross_path}")
401
+ return mpy_cross_path
402
+
403
+ # Check in the Scripts/bin directory of the current Python environment
404
+ bin_dir = "Scripts" if sys.platform == "win32" else "bin"
405
+ env_path = os.path.join(os.path.dirname(sys.executable), bin_dir, "mpy-cross")
406
+ if os.path.exists(env_path):
407
+ log.info(f"Found mpy-cross executable in Python environment: {env_path}")
408
+ return env_path
409
+ raise FileNotFoundError("mpy-cross executable not found in PATH or Python environment")
410
+ except Exception as e:
411
+ log.debug(f"Error locating mpy-cross: {e}")
412
+ raise FileNotFoundError("mpy-cross executable not found in PATH or Python environment") from e
413
+
414
+ def run_mpy_cross(version: str, source_file, _target):
415
+ """Run mpy-cross using --compat if needed"""
394
416
  log.info(f"Compiling with mpy-cross version: {version}")
395
417
  if version in SET_PREVIEW:
396
418
  version = ""
397
419
  if version:
398
- version = "~=" + version.lstrip("v")
420
+ version = version.lstrip("v")
421
+ compat = ["--compat", version] if version else []
399
422
 
400
- cmd = ["pipx", "run", f"mpy-cross{version}"] if version else ["pipx", "run", "mpy-cross"]
401
- # Add params
402
- cmd += ["-O2", str(source_file), "-o", str(_target), "-s", "createstubs.py"]
423
+ cmd = [locate_mpy_cross() ] + compat + ["-O2", str(source_file), "-o", str(_target), "-s", "createstubs.py"]
403
424
  log.trace(" ".join(cmd))
404
425
  result = subprocess.run(
405
426
  cmd, capture_output=True, text=True, encoding="utf-8"
@@ -56,6 +56,15 @@ def get_package(
56
56
  version=version,
57
57
  json_data=package_info,
58
58
  )
59
+ # TODO @Josverl: Check or update stub_sources in len < 3
60
+ EXPECTED_STUBS = 3
61
+ if len(p_db.stub_sources) < EXPECTED_STUBS:
62
+ log.warning(f"Package {pkg_name} has less than 3 stub sources, updating...")
63
+ stub_sources = combo_sources(family, port, board, clean_version(p_db.mpy_version, flat=True))
64
+ if len(stub_sources) >= EXPECTED_STUBS:
65
+ p_db.stub_sources = stub_sources
66
+ p_db.update_sources()
67
+ log.info(f"Updated stub sources for {pkg_name} to {p_db.stub_sources}")
59
68
  return p_db
60
69
 
61
70
  log.debug(f"No package found for {pkg_name} in database, creating new package")
@@ -115,13 +124,13 @@ def create_package(
115
124
  create and initialize a package with the correct sources
116
125
  """
117
126
  ver_flat = clean_version(mpy_version, flat=True)
118
- stubs: StubSources = []
127
+ stub_sources: StubSources = []
119
128
  # if pkg_type != COMBO_STUBS:
120
129
  # raise ValueError("Not Supported")
121
130
 
122
131
  assert port != "", "port must be specified for combo stubs"
123
- stubs = combo_sources(family, port, board, ver_flat)
124
- return StubPackage(pkg_name, port=port, board=board, version=mpy_version, stubs=stubs)
132
+ stub_sources = combo_sources(family, port, board, ver_flat)
133
+ return StubPackage(pkg_name, port=port, board=board, version=mpy_version, stub_sources=stub_sources)
125
134
 
126
135
 
127
136
  def combo_sources(family: str, port: str, board: str, ver_flat: str) -> StubSources:
@@ -210,7 +210,7 @@ class Builder(VersionedPackage):
210
210
  board: str = GENERIC_U,
211
211
  variant: Optional[str] = None,
212
212
  description: str = "MicroPython stubs",
213
- stubs: Optional[StubSources] = None,
213
+ stub_sources: Optional[StubSources] = None,
214
214
  # json_data: Optional[Dict[str, Any]] = None,
215
215
  ): # port: str, board: str
216
216
  super().__init__(package_name=package_name, mpy_version=mpy_version)
@@ -221,7 +221,7 @@ class Builder(VersionedPackage):
221
221
  self.board = board
222
222
  self.variant = variant or ""
223
223
  self.description = description
224
- self.stub_sources = stubs or []
224
+ self.stub_sources = stub_sources or []
225
225
  self.hash = None # intial hash
226
226
  """Hash of all the files in the package"""
227
227
  self.stub_hash = None # intial hash
@@ -323,7 +323,7 @@ class Builder(VersionedPackage):
323
323
  for n in range(len(self.stub_sources)):
324
324
  stub_type, src_path = self.stub_sources[n]
325
325
  try:
326
- log.debug(f"Copying {stub_type} from {src_path}")
326
+ log.debug(f"Copy {stub_type:<20} from {src_path}")
327
327
  self.copy_folder(stub_type, src_path)
328
328
  except OSError as e:
329
329
  if stub_type != StubSource.FROZEN:
@@ -587,7 +587,7 @@ class PoetryBuilder(Builder):
587
587
  mpy_version: str = "0.0.1",
588
588
  board: str = GENERIC_U,
589
589
  description: str = "MicroPython stubs",
590
- stubs: Optional[StubSources] = None,
590
+ stub_sources: Optional[StubSources] = None,
591
591
  json_data: Optional[Dict[str, Any]] = None,
592
592
  ):
593
593
  super().__init__(
@@ -596,7 +596,7 @@ class PoetryBuilder(Builder):
596
596
  port=port,
597
597
  board=board,
598
598
  description=description,
599
- stubs=stubs,
599
+ stub_sources=stub_sources,
600
600
  )
601
601
 
602
602
  # -----------------------------------------------
@@ -799,7 +799,7 @@ class StubPackage(PoetryBuilder):
799
799
  board: str = GENERIC_U,
800
800
  version: str = "0.0.1",
801
801
  description: str = "MicroPython stubs",
802
- stubs: Optional[StubSources] = None,
802
+ stub_sources: Optional[StubSources] = None,
803
803
  json_data: Optional[Dict[str, Any]] = None,
804
804
  ):
805
805
  """
@@ -826,7 +826,7 @@ class StubPackage(PoetryBuilder):
826
826
  port=port,
827
827
  board=board,
828
828
  description=description,
829
- stubs=stubs or [],
829
+ stub_sources=stub_sources or [],
830
830
  )
831
831
  self.port = port
832
832
  self.board = board
@@ -840,11 +840,6 @@ class StubPackage(PoetryBuilder):
840
840
 
841
841
  self.create_update_pyproject_toml()
842
842
 
843
- # self.stub_sources: StubSources = []
844
- # # save the stub sources
845
- # if stubs:
846
- # self.stub_sources = stubs
847
-
848
843
  self.status: Status = Status(
849
844
  {
850
845
  "result": "-",
@@ -445,6 +445,12 @@ PARAM_FIXES = [
445
445
  "(ip, subnet, gateway, dns):Optional[Any]=None",
446
446
  "configtuple: Optional[Tuple]",
447
447
  ),
448
+ # network.ipconfig
449
+ Fix(
450
+ "param=value",
451
+ "param:Optional[str]=None",
452
+ name="ipconfig",
453
+ ),
448
454
  # framebuffer
449
455
  # unresolvable parameter defaults # FrameBuffer: def __init__
450
456
  Fix(
@@ -69,10 +69,19 @@ from typing import List, Optional, Tuple
69
69
 
70
70
  from mpflash.logger import log
71
71
  from mpflash.versions import V_PREVIEW
72
- from stubber.rst import (CHILD_PARENT_CLASS, MODULE_GLUE, PARAM_FIXES,
73
- PARAM_RE_FIXES, RST_DOC_FIXES, TYPING_IMPORT,
74
- ClassSourceDict, FunctionSourceDict, ModuleSourceDict,
75
- return_type_from_context)
72
+
73
+ from stubber.rst import (
74
+ CHILD_PARENT_CLASS,
75
+ MODULE_GLUE,
76
+ PARAM_FIXES,
77
+ PARAM_RE_FIXES,
78
+ RST_DOC_FIXES,
79
+ TYPING_IMPORT,
80
+ ClassSourceDict,
81
+ FunctionSourceDict,
82
+ ModuleSourceDict,
83
+ return_type_from_context,
84
+ )
76
85
  from stubber.rst.lookup import Fix
77
86
  from stubber.utils.config import CONFIG
78
87
 
@@ -496,8 +505,8 @@ class RSTParser(RSTReader):
496
505
  self.read_file(file_path)
497
506
  self.parse()
498
507
  # reset this file to done
499
- self.rst_text = []
500
- self.line_no = 1
508
+ # self.rst_text = []
509
+ # self.line_no = 1
501
510
 
502
511
  def parse_module(self):
503
512
  "parse a module tag and set the module's docstring"
@@ -78,23 +78,11 @@ def get_rst_sources(rst_path: Path, pattern: str) -> List[Path]:
78
78
  def make_docstubs(
79
79
  dst_path: Path, v_tag: str, release: str, suffix: str, files: List[Path], clean_rst: bool
80
80
  ):
81
- """Create the docstubs"""
81
+ """Create docstubs from the list of rst files"""
82
82
 
83
83
  for file in files:
84
- reader = RSTWriter(v_tag)
85
- reader.clean_rst = clean_rst
86
- reader.source_release = release
87
- log.debug(f"Reading: {file}")
88
- reader.read_file(file)
89
- reader.parse()
90
- # Destination = "module.__init__.pyi"
91
- if "." in file.stem:
92
- target = dst_path / f"{(file.stem).replace('.', '/')}{suffix}"
93
- else:
94
- target = dst_path / file.stem / f"__init__{suffix}"
95
- # fname = (dst_path / file.name).with_suffix(suffix)
96
- reader.write_file(target)
97
- del reader
84
+ make_docstub(file, dst_path, v_tag, release, suffix, clean_rst)
85
+
98
86
  for name in U_MODULES:
99
87
  # create a file "umodule.pyi" for each module
100
88
  # and add a line : from module import *
@@ -107,3 +95,28 @@ def make_docstubs(
107
95
  f.write("# Allow the use of micro-module notation \n\n")
108
96
  f.write(f"from {name} import * # type: ignore\n")
109
97
  f.flush()
98
+
99
+
100
+ def make_docstub(
101
+ file: Path,
102
+ dst_path: Path,
103
+ v_tag: str,
104
+ release: str,
105
+ suffix: str,
106
+ clean_rst: bool,
107
+ ):
108
+ """Create a docstub from a single rst file"""
109
+ reader = RSTWriter(v_tag)
110
+ reader.clean_rst = clean_rst
111
+ reader.source_release = release
112
+ log.debug(f"Reading: {file}")
113
+ reader.read_file(file)
114
+ reader.parse()
115
+
116
+ if "." in file.stem:
117
+ target = dst_path / f"{(file.stem).replace('.', '/')}{suffix}"
118
+ else:
119
+ target = dst_path / file.stem / f"__init__{suffix}"
120
+
121
+ reader.write_file(target)
122
+ del reader