micropython-stubber 1.13.8__tar.gz → 1.14.1__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 (112) hide show
  1. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/PKG-INFO +3 -2
  2. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/pyproject.toml +30 -5
  3. micropython_stubber-1.14.1/src/stubber/__init__.py +4 -0
  4. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs.py +71 -27
  5. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_db.py +15 -14
  6. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_db_min.py +85 -84
  7. micropython_stubber-1.14.1/src/stubber/board/createstubs_db_mpy.mpy +0 -0
  8. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_info.py +2 -6
  9. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_lvgl.py +15 -14
  10. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_lvgl_min.py +6 -6
  11. micropython_stubber-1.14.1/src/stubber/board/createstubs_lvgl_mpy.mpy +0 -0
  12. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_mem.py +15 -14
  13. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/createstubs_mem_min.py +46 -46
  14. micropython_stubber-1.14.1/src/stubber/board/createstubs_mem_mpy.mpy +0 -0
  15. micropython_stubber-1.14.1/src/stubber/board/createstubs_min.py +271 -0
  16. micropython_stubber-1.14.1/src/stubber/board/createstubs_mpy.mpy +0 -0
  17. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/modulelist.txt +12 -0
  18. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/pyrightconfig.json +3 -3
  19. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/_partials/modules_reader.py +13 -8
  20. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/add_method.py +9 -6
  21. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/merge_docstub.py +34 -8
  22. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/modify_list.py +9 -5
  23. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/build_cmd.py +3 -2
  24. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/enrich_folder_cmd.py +2 -2
  25. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/upd_module_list_cmd.py +5 -2
  26. micropython_stubber-1.14.1/src/stubber/data/board_info.csv +160 -0
  27. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/data/board_info.json +182 -174
  28. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/get_cpython.py +1 -1
  29. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/get_lobo.py +1 -1
  30. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/minify.py +59 -36
  31. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/candidates.py +10 -8
  32. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/merge_docstubs.py +10 -6
  33. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/publish.py +12 -2
  34. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/stubpacker.py +66 -25
  35. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/lookup.py +172 -47
  36. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/output_dict.py +92 -15
  37. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/reader.py +98 -46
  38. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/rst_utils.py +53 -23
  39. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/tools/manifestfile.py +608 -614
  40. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/update_module_list.py +2 -2
  41. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/config.py +31 -8
  42. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/repos.py +4 -4
  43. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/versions.py +3 -3
  44. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/variants.py +8 -5
  45. micropython_stubber-1.13.8/setup.py +0 -72
  46. micropython_stubber-1.13.8/src/stubber/__init__.py +0 -4
  47. micropython_stubber-1.13.8/src/stubber/board/createstubs_db_mpy.mpy +0 -0
  48. micropython_stubber-1.13.8/src/stubber/board/createstubs_lvgl_mpy.mpy +0 -0
  49. micropython_stubber-1.13.8/src/stubber/board/createstubs_mem_mpy.mpy +0 -0
  50. micropython_stubber-1.13.8/src/stubber/board/createstubs_min.py +0 -271
  51. micropython_stubber-1.13.8/src/stubber/board/createstubs_mpy.mpy +0 -0
  52. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/LICENSE +0 -0
  53. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/readme.md +0 -0
  54. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/basicgit.py +0 -0
  55. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/board_info.csv +0 -0
  56. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/boot.py +0 -0
  57. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/logging.py +0 -0
  58. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/board/main.py +0 -0
  59. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/__init__.py +0 -0
  60. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/_partials/__init__.py +0 -0
  61. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/_partials/db_main.py +0 -0
  62. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/_partials/lvgl_main.py +0 -0
  63. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/add_comment.py +0 -0
  64. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/board.py +0 -0
  65. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/enrich.py +0 -0
  66. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/codemod/utils.py +0 -0
  67. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/__init__.py +0 -0
  68. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/cli.py +0 -0
  69. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/clone_cmd.py +0 -0
  70. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/config_cmd.py +0 -0
  71. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/get_core_cmd.py +0 -0
  72. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/get_docstubs_cmd.py +0 -0
  73. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/get_frozen_cmd.py +0 -0
  74. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/get_lobo_cmd.py +0 -0
  75. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/merge_cmd.py +0 -0
  76. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/minify_cmd.py +0 -0
  77. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/publish_cmd.py +0 -0
  78. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/stub_cmd.py +0 -0
  79. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/switch_cmd.py +0 -0
  80. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/upd_fallback_cmd.py +0 -0
  81. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/commands/variants_cmd.py +0 -0
  82. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/cst_transformer.py +0 -0
  83. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/data/micropython_tags.csv +0 -0
  84. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/data/requirements-core-micropython.txt +0 -0
  85. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/data/requirements-core-pycopy.txt +0 -0
  86. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/downloader.py +0 -0
  87. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/freeze/__init__.py +0 -0
  88. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/freeze/common.py +0 -0
  89. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/freeze/freeze_folder.py +0 -0
  90. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/freeze/freeze_manifest_2.py +0 -0
  91. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/freeze/get_frozen.py +0 -0
  92. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/__init__.py +0 -0
  93. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/bump.py +0 -0
  94. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/database.py +0 -0
  95. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/enums.py +0 -0
  96. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/missing_class_methods.py +0 -0
  97. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/package.py +0 -0
  98. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/publish/pypi.py +0 -0
  99. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/__init__.py +0 -0
  100. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/classsort.py +0 -0
  101. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/rst/report_return.py +0 -0
  102. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/stubber.py +0 -0
  103. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/stubs_from_docs.py +0 -0
  104. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/tools/__init__.py +0 -0
  105. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/tools/readme.md +0 -0
  106. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/update_fallback.py +0 -0
  107. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/__init__.py +0 -0
  108. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/makeversionhdr.py +0 -0
  109. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/manifest.py +0 -0
  110. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/post.py +0 -0
  111. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/stubmaker.py +0 -0
  112. {micropython_stubber-1.13.8 → micropython_stubber-1.14.1}/src/stubber/utils/typed_config_toml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: micropython-stubber
3
- Version: 1.13.8
3
+ Version: 1.14.1
4
4
  Summary: Tooling to create and maintain stubs for MicroPython
5
5
  Home-page: https://github.com/Josverl/micropython-stubber#readme
6
6
  License: MIT
@@ -26,13 +26,14 @@ Requires-Dist: click (>=8.1.3,<9.0.0)
26
26
  Requires-Dist: esptool (>=4.4,<5.0) ; extra == "tools"
27
27
  Requires-Dist: importlib-metadata (>=1.0,<2.0) ; python_version < "3.8"
28
28
  Requires-Dist: libcst (>=0.4.9,<0.5.0)
29
- Requires-Dist: loguru (>=0.6.0,<0.7.0)
29
+ Requires-Dist: loguru (>=0.6,<0.8)
30
30
  Requires-Dist: mypy (==1.2.0)
31
31
  Requires-Dist: packaging (>=21.3,<24.0)
32
32
  Requires-Dist: pipx (>=1.1.0,<2.0.0)
33
33
  Requires-Dist: pygithub (>=1.57,<2.0)
34
34
  Requires-Dist: pypi-simple (>=1.0.0,<2.0.0)
35
35
  Requires-Dist: pyright (>=1.1.265,<2.0.0)
36
+ Requires-Dist: pyserial (>=3.5,<4.0)
36
37
  Requires-Dist: pysondb-v2 (>=2.1.0,<3.0.0)
37
38
  Requires-Dist: python-minifier (>=2.7.0,<3.0.0)
38
39
  Requires-Dist: requests (>=2.28.0,<3.0.0)
@@ -8,7 +8,7 @@ repo-path = "./repos"
8
8
 
9
9
  [tool.poetry]
10
10
  name = "micropython-stubber"
11
- version = "1.13.8"
11
+ version = "1.14.1"
12
12
  description = "Tooling to create and maintain stubs for MicroPython"
13
13
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
14
14
  license = "MIT"
@@ -56,7 +56,7 @@ cachetools = "^5.3.0"
56
56
  click = "^8.1.3"
57
57
  esptool = { version = "^4.4", optional = true }
58
58
  importlib-metadata = { version = "^1.0", python = "<3.8" }
59
- loguru = "^0.6.0"
59
+ loguru = ">=0.6,<0.8"
60
60
  packaging = ">=21.3,<24.0"
61
61
  pipx = "^1.1.0"
62
62
  pygithub = "^1.57"
@@ -68,6 +68,7 @@ tenacity = "^8.2.2"
68
68
  tomli = { version = "^2.0.1", python = "<3.11" }
69
69
  tomli-w = "^1.0.0"
70
70
  typed-config = "^1.3.0"
71
+ pyserial = "^3.5"
71
72
 
72
73
  [tool.poetry.extras]
73
74
  tools = ["esptool"]
@@ -75,7 +76,7 @@ tools = ["esptool"]
75
76
  [tool.poetry.group.docs]
76
77
  optional = true
77
78
  [tool.poetry.group.docs.dependencies]
78
- Sphinx = "^4.4.0"
79
+ Sphinx = ">=4.4,<6.0"
79
80
  myst-parser = ">=0.17,<0.19"
80
81
  sphinx_rtd_theme = "^1.0.0"
81
82
  sphinx-autoapi = "^1.9.0"
@@ -97,6 +98,10 @@ pytest-mock = "^3.10.0"
97
98
  sourcery-cli = "^1.0.3"
98
99
  mpremote = { git = "https://github.com/Josverl/mpremote", subdirectory = "tools/mpremote", optional = true }
99
100
  ipykernel = "^6.23.1"
101
+ fasteners = "^0.19"
102
+ python-dotenv = "^1.0.0"
103
+
104
+
100
105
 
101
106
  [build-system]
102
107
  requires = ["poetry-core>=1.0.0"]
@@ -205,16 +210,33 @@ exclude = '''
205
210
  minversion = "7.0"
206
211
  python_functions = ["test_", "*_test"]
207
212
  python_files = ["test_*.py", "*_test.py"]
208
- testpaths = ["tests", "src"]
213
+ testpaths = ["tests", "src", "snippets"]
214
+ norecursedirs = [
215
+ "repos",
216
+ "typings*",
217
+ ".svn",
218
+ "_build",
219
+ "tmp*",
220
+ ".*",
221
+ "build",
222
+ "dist",
223
+ "{arch}",
224
+ "*.egg",
225
+ ]
209
226
  junit_family = "xunit1"
210
227
 
211
- addopts = "-v -sv -m 'not basicgit'"
228
+ addopts = "--verbose --capture=no -m 'not basicgit'"
229
+ # -m 'not snippets'
230
+ # --numprocesses=auto
231
+ # -m MARKEXPR Only run tests matching given mark expression. For example: -m 'mark1 and not mark2'.
232
+ # -n --numprocesses=numprocesses -
212
233
 
213
234
  markers = [
214
235
  "slow: marks tests as slow (deselect with '-m \"not slow\"')",
215
236
  "integration: Integration tests (slower)",
216
237
  "basicgit: marks tests in the basicgit module that manipulate the checkout",
217
238
  "mocked: to replace/compensate for most of the slow and git tests",
239
+ "snippets: test snippets to check the stubs",
218
240
  #
219
241
  "minified: marks test of the minified version of createstubs",
220
242
  "minify: marks test of the minification of createstubs",
@@ -227,6 +249,9 @@ markers = [
227
249
  "win32: run test only on Windows",
228
250
  "linux: run test only on linux",
229
251
  "darwin: run test only on Mac",
252
+ "version: run test only on specific version",
253
+ "1.19.0: run test only on 1.19.0",
254
+ "1.20.0: run test only on 1.20.0",
230
255
  ]
231
256
 
232
257
  # coverage reports
@@ -0,0 +1,4 @@
1
+ """get the version"""
2
+
3
+
4
+ __version__ = "1.14.1"
@@ -5,9 +5,9 @@ Create stubs for (all) modules on a MicroPython board
5
5
  # pylint: disable= invalid-name, missing-function-docstring, import-outside-toplevel, logging-not-lazy
6
6
  import gc
7
7
  import logging
8
+ import os
8
9
  import sys
9
10
 
10
- import uos as os
11
11
  from ujson import dumps
12
12
 
13
13
  try:
@@ -20,7 +20,7 @@ try:
20
20
  except ImportError:
21
21
  from ucollections import OrderedDict # type: ignore
22
22
 
23
- __version__ = "v1.13.8"
23
+ __version__ = "v1.14.1"
24
24
  ENOENT = 2
25
25
  _MAX_CLASS_LEVEL = 2 # Max class nesting
26
26
  LIBS = [".", "/lib", "/sd/lib", "/flash/lib", "lib"]
@@ -81,7 +81,7 @@ class Stubber:
81
81
  "example_pub_button.py",
82
82
  ]
83
83
  # there is no option to discover modules from micropython, list is read from an external file.
84
- self.modules = []
84
+ self.modules = [] # type: list[str]
85
85
 
86
86
  def get_obj_attributes(self, item_instance: object):
87
87
  "extract information of the objects members and attributes"
@@ -110,7 +110,11 @@ class Stubber:
110
110
  order = 4
111
111
  _result.append((name, repr(val), repr(type(val)), val, order))
112
112
  except AttributeError as e:
113
- _errors.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(name, item_instance, e))
113
+ _errors.append(
114
+ "Couldn't get attribute '{}' from object '{}', Err: {}".format(
115
+ name, item_instance, e
116
+ )
117
+ )
114
118
  except MemoryError as e:
115
119
  print("MemoryError: {}".format(e))
116
120
  sleep(1)
@@ -174,24 +178,31 @@ class Stubber:
174
178
  try:
175
179
  new_module = __import__(module_name, None, None, ("*"))
176
180
  m1 = gc.mem_free() # type: ignore
177
- self._log.info("Stub module: {:<25} to file: {:<70} mem:{:>5}".format(module_name, fname, m1))
181
+ self._log.info(
182
+ "Stub module: {:<25} to file: {:<70} mem:{:>5}".format(module_name, fname, m1)
183
+ )
178
184
 
179
185
  except ImportError:
180
- self._log.warning("Skip module: {:<25} {:<79}".format(module_name, "Module not found."))
186
+ self._log.warning(
187
+ "Skip module: {:<25} {:<79}".format(module_name, "Module not found.")
188
+ )
181
189
  return False
182
190
 
183
191
  # Start a new file
184
192
  ensure_folder(file_name)
185
193
  with open(file_name, "w") as fp:
186
194
  # todo: improve header
195
+ info_ = str(self.info).replace("OrderedDict(", "").replace("})", "}")
187
196
  s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(
188
- module_name, self._fwid, self.info, __version__
197
+ module_name, self._fwid, info_, __version__
189
198
  )
190
199
  fp.write(s)
191
- fp.write("from typing import Any\n\n")
200
+ fp.write("from typing import Any\nfrom _typeshed import Incomplete\n\n")
192
201
  self.write_object_stub(fp, new_module, module_name, "")
193
202
 
194
- self._report.append('{{"module": "{}", "file": "{}"}}'.format(module_name, file_name.replace("\\", "/")))
203
+ self._report.append(
204
+ '{{"module": "{}", "file": "{}"}}'.format(module_name, file_name.replace("\\", "/"))
205
+ )
195
206
 
196
207
  if module_name not in {"os", "sys", "logging", "gc"}:
197
208
  # try to unload the module unless we use it
@@ -206,7 +217,9 @@ class Stubber:
206
217
  gc.collect()
207
218
  return True
208
219
 
209
- def write_object_stub(self, fp, object_expr: object, obj_name: str, indent: str, in_class: int = 0):
220
+ def write_object_stub(
221
+ self, fp, object_expr: object, obj_name: str, indent: str, in_class: int = 0
222
+ ):
210
223
  "Write a module/object stub to an open file. Can be called recursive."
211
224
  gc.collect()
212
225
  if object_expr in self.problematic:
@@ -221,8 +234,8 @@ class Stubber:
221
234
 
222
235
  for item_name, item_repr, item_type_txt, item_instance, _ in items:
223
236
  # name_, repr_(value), type as text, item_instance, order
224
- # do not create stubs for these primitives
225
237
  if item_name in ["classmethod", "staticmethod", "BaseException", "Exception"]:
238
+ # do not create stubs for these primitives
226
239
  continue
227
240
  if item_name[0].isdigit():
228
241
  self._log.warning("NameError: invalid name {}".format(item_name))
@@ -265,23 +278,29 @@ class Stubber:
265
278
  s = indent + " def __init__(self, *argv, **kwargs) -> None:\n"
266
279
  s += indent + " ...\n\n"
267
280
  fp.write(s)
268
- elif "method" in item_type_txt or "function" in item_type_txt:
269
- self._log.debug("# def {1} function or method, type = '{0}'".format(item_type_txt, item_name))
281
+ elif any(word in item_type_txt for word in ["method", "function", "closure"]):
282
+ self._log.debug(
283
+ "# def {1} function/method/closure, type = '{0}'".format(
284
+ item_type_txt, item_name
285
+ )
286
+ )
270
287
  # module Function or class method
271
288
  # will accept any number of params
272
- # return type Any
273
- ret = "Any"
289
+ # return type Any/Incomplete
290
+ ret = "Incomplete"
274
291
  first = ""
275
292
  # Self parameter only on class methods/functions
276
293
  if in_class > 0:
277
294
  first = "self, "
278
295
  # class method - add function decoration
279
296
  if "bound_method" in item_type_txt or "bound_method" in item_repr:
280
- s = "{}@classmethod\n".format(indent) + "{}def {}(cls, *args, **kwargs) -> {}:\n".format(
281
- indent, item_name, ret
282
- )
297
+ s = "{}@classmethod\n".format(
298
+ indent
299
+ ) + "{}def {}(cls, *args, **kwargs) -> {}:\n".format(indent, item_name, ret)
283
300
  else:
284
- s = "{}def {}({}*args, **kwargs) -> {}:\n".format(indent, item_name, first, ret)
301
+ s = "{}def {}({}*args, **kwargs) -> {}:\n".format(
302
+ indent, item_name, first, ret
303
+ )
285
304
  s += indent + " ...\n\n"
286
305
  fp.write(s)
287
306
  self._log.debug("\n" + s)
@@ -306,9 +325,11 @@ class Stubber:
306
325
  if t not in ["object", "set", "frozenset"]:
307
326
  # Possibly default others to item_instance object ?
308
327
  # https://docs.python.org/3/tutorial/classes.html#item_instance-objects
309
- t = "Any"
328
+ t = "Incomplete"
310
329
  # Requires Python 3.6 syntax, which is OK for the stubs/pyi
311
- s = "{0}{1} : {2} ## {3} = {4}\n".format(indent, item_name, t, item_type_txt, item_repr)
330
+ s = "{0}{1} : {2} ## {3} = {4}\n".format(
331
+ indent, item_name, t, item_type_txt, item_repr
332
+ )
312
333
  fp.write(s)
313
334
  self._log.debug("\n" + s)
314
335
  else:
@@ -316,7 +337,7 @@ class Stubber:
316
337
  self._log.debug("# all other, type = '{0}'".format(item_type_txt))
317
338
  fp.write("# all other, type = '{0}'\n".format(item_type_txt))
318
339
 
319
- fp.write(indent + item_name + " # type: Any\n")
340
+ fp.write(indent + item_name + " # type: Incomplete\n")
320
341
 
321
342
  del items
322
343
  del errors
@@ -359,7 +380,11 @@ class Stubber:
359
380
 
360
381
  def report(self, filename: str = "modules.json"):
361
382
  "create json with list of exported modules"
362
- self._log.info("Created stubs for {} modules on board {}\nPath: {}".format(len(self._report), self._fwid, self.path))
383
+ self._log.info(
384
+ "Created stubs for {} modules on board {}\nPath: {}".format(
385
+ len(self._report), self._fwid, self.path
386
+ )
387
+ )
363
388
  f_name = "{}/{}".format(self.path, filename)
364
389
  self._log.info("Report file: {}".format(f_name))
365
390
  gc.collect()
@@ -432,7 +457,9 @@ def _info(): # type:() -> dict[str, str]
432
457
  "version": "",
433
458
  "build": "",
434
459
  "ver": "",
435
- "port": "stm32" if sys.platform.startswith("pyb") else sys.platform, # port: esp32 / win32 / linux / stm32
460
+ "port": "stm32"
461
+ if sys.platform.startswith("pyb")
462
+ else sys.platform, # port: esp32 / win32 / linux / stm32
436
463
  "board": "GENERIC",
437
464
  "cpu": "",
438
465
  "mpy": "",
@@ -444,7 +471,11 @@ def _info(): # type:() -> dict[str, str]
444
471
  except AttributeError:
445
472
  pass
446
473
  try:
447
- machine = sys.implementation._machine if "_machine" in dir(sys.implementation) else os.uname().machine
474
+ machine = (
475
+ sys.implementation._machine
476
+ if "_machine" in dir(sys.implementation)
477
+ else os.uname().machine
478
+ )
448
479
  info["board"] = machine.strip()
449
480
  info["cpu"] = machine.split("with")[1].strip()
450
481
  info["mpy"] = (
@@ -514,7 +545,8 @@ def _info(): # type:() -> dict[str, str]
514
545
  if (
515
546
  info["version"]
516
547
  and info["version"].endswith(".0")
517
- and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.20.0 do not have a micro .0
548
+ and info["version"]
549
+ >= "1.10.0" # versions from 1.10.0 to 1.20.0 do not have a micro .0
518
550
  and info["version"] <= "1.19.9"
519
551
  ):
520
552
  # drop the .0 for newer releases
@@ -642,8 +674,10 @@ def main():
642
674
  stubber.modules = [
643
675
  "WM8960",
644
676
  "_OTA",
677
+ "_asyncio",
645
678
  "_boot_fat",
646
679
  "_coap",
680
+ "_espnow",
647
681
  "_flash_control_OTA",
648
682
  "_main_pybytes",
649
683
  "_mqtt",
@@ -679,10 +713,17 @@ def main():
679
713
  "aioble/peripheral",
680
714
  "aioble/security",
681
715
  "aioble/server",
716
+ "aioespnow",
682
717
  "ak8963",
683
718
  "apa102",
684
719
  "apa106",
685
720
  "array",
721
+ "asyncio/__init__",
722
+ "asyncio/core",
723
+ "asyncio/event",
724
+ "asyncio/funcs",
725
+ "asyncio/lock",
726
+ "asyncio/stream",
686
727
  "binascii",
687
728
  "bluetooth",
688
729
  "breakout_as7262",
@@ -713,6 +754,7 @@ def main():
713
754
  "crypto",
714
755
  "cryptolib",
715
756
  "curl",
757
+ "deflate",
716
758
  "dht",
717
759
  "display",
718
760
  "display_driver_utils",
@@ -722,6 +764,7 @@ def main():
722
764
  "esp",
723
765
  "esp32",
724
766
  "espidf",
767
+ "espnow",
725
768
  "flashbdev",
726
769
  "framebuf",
727
770
  "freesans20",
@@ -757,6 +800,7 @@ def main():
757
800
  "microWebTemplate",
758
801
  "micropython",
759
802
  "mip",
803
+ "mip/__init__",
760
804
  "motor",
761
805
  "mpu6500",
762
806
  "mpu9250",
@@ -875,7 +919,7 @@ if __name__ == "__main__" or is_micropython():
875
919
  pass
876
920
  if not file_exists("no_auto_stubber.txt"):
877
921
  try:
878
- gc.threshold(4 * 1024)
922
+ gc.threshold(4 * 1024) # type: ignore
879
923
  gc.enable()
880
924
  except BaseException:
881
925
  pass
@@ -18,15 +18,15 @@ 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.13.8
21
+ This variant was generated from createstubs.py by micropython-stubber v1.14.1
22
22
  """
23
23
  # Copyright (c) 2019-2023 Jos Verlinde
24
24
  # pylint: disable= invalid-name, missing-function-docstring, import-outside-toplevel, logging-not-lazy
25
25
  import gc
26
26
  import logging
27
+ import os
27
28
  import sys
28
29
 
29
- import uos as os
30
30
  from ujson import dumps
31
31
 
32
32
  try:
@@ -39,7 +39,7 @@ try:
39
39
  except ImportError:
40
40
  from ucollections import OrderedDict # type: ignore
41
41
 
42
- __version__ = "v1.13.8"
42
+ __version__ = "v1.14.1"
43
43
  ENOENT = 2
44
44
  _MAX_CLASS_LEVEL = 2 # Max class nesting
45
45
  LIBS = [".", "/lib", "/sd/lib", "/flash/lib", "lib"]
@@ -100,7 +100,7 @@ class Stubber:
100
100
  "example_pub_button.py",
101
101
  ]
102
102
  # there is no option to discover modules from micropython, list is read from an external file.
103
- self.modules = []
103
+ self.modules = [] # type: list[str]
104
104
 
105
105
  def get_obj_attributes(self, item_instance: object):
106
106
  "extract information of the objects members and attributes"
@@ -203,9 +203,10 @@ class Stubber:
203
203
  ensure_folder(file_name)
204
204
  with open(file_name, "w") as fp:
205
205
  # todo: improve header
206
- s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(module_name, self._fwid, self.info, __version__)
206
+ info_ = str(self.info).replace("OrderedDict(", "").replace("})", "}")
207
+ s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(module_name, self._fwid, info_, __version__)
207
208
  fp.write(s)
208
- fp.write("from typing import Any\n\n")
209
+ fp.write("from typing import Any\nfrom _typeshed import Incomplete\n\n")
209
210
  self.write_object_stub(fp, new_module, module_name, "")
210
211
 
211
212
  self._report.append('{{"module": "{}", "file": "{}"}}'.format(module_name, file_name.replace("\\", "/")))
@@ -238,8 +239,8 @@ class Stubber:
238
239
 
239
240
  for item_name, item_repr, item_type_txt, item_instance, _ in items:
240
241
  # name_, repr_(value), type as text, item_instance, order
241
- # do not create stubs for these primitives
242
242
  if item_name in ["classmethod", "staticmethod", "BaseException", "Exception"]:
243
+ # do not create stubs for these primitives
243
244
  continue
244
245
  if item_name[0].isdigit():
245
246
  self._log.warning("NameError: invalid name {}".format(item_name))
@@ -282,12 +283,12 @@ class Stubber:
282
283
  s = indent + " def __init__(self, *argv, **kwargs) -> None:\n"
283
284
  s += indent + " ...\n\n"
284
285
  fp.write(s)
285
- elif "method" in item_type_txt or "function" in item_type_txt:
286
- self._log.debug("# def {1} function or method, type = '{0}'".format(item_type_txt, item_name))
286
+ elif any(word in item_type_txt for word in ["method", "function", "closure"]):
287
+ self._log.debug("# def {1} function/method/closure, type = '{0}'".format(item_type_txt, item_name))
287
288
  # module Function or class method
288
289
  # will accept any number of params
289
- # return type Any
290
- ret = "Any"
290
+ # return type Any/Incomplete
291
+ ret = "Incomplete"
291
292
  first = ""
292
293
  # Self parameter only on class methods/functions
293
294
  if in_class > 0:
@@ -321,7 +322,7 @@ class Stubber:
321
322
  if t not in ["object", "set", "frozenset"]:
322
323
  # Possibly default others to item_instance object ?
323
324
  # https://docs.python.org/3/tutorial/classes.html#item_instance-objects
324
- t = "Any"
325
+ t = "Incomplete"
325
326
  # Requires Python 3.6 syntax, which is OK for the stubs/pyi
326
327
  s = "{0}{1} : {2} ## {3} = {4}\n".format(indent, item_name, t, item_type_txt, item_repr)
327
328
  fp.write(s)
@@ -331,7 +332,7 @@ class Stubber:
331
332
  self._log.debug("# all other, type = '{0}'".format(item_type_txt))
332
333
  fp.write("# all other, type = '{0}'\n".format(item_type_txt))
333
334
 
334
- fp.write(indent + item_name + " # type: Any\n")
335
+ fp.write(indent + item_name + " # type: Incomplete\n")
335
336
 
336
337
  del items
337
338
  del errors
@@ -732,7 +733,7 @@ if __name__ == "__main__" or is_micropython():
732
733
  pass
733
734
  if not file_exists("no_auto_stubber.txt"):
734
735
  try:
735
- gc.threshold(4 * 1024)
736
+ gc.threshold(4 * 1024) # type: ignore
736
737
  gc.enable()
737
738
  except BaseException:
738
739
  pass