micropython-stubber 1.20.2__py3-none-any.whl → 1.20.5__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 (51) hide show
  1. {micropython_stubber-1.20.2.dist-info → micropython_stubber-1.20.5.dist-info}/METADATA +5 -4
  2. {micropython_stubber-1.20.2.dist-info → micropython_stubber-1.20.5.dist-info}/RECORD +51 -46
  3. {micropython_stubber-1.20.2.dist-info → micropython_stubber-1.20.5.dist-info}/WHEEL +1 -1
  4. mpflash/mpflash/ask_input.py +24 -14
  5. mpflash/mpflash/bootloader/__init__.py +36 -0
  6. mpflash/mpflash/bootloader/manual.py +102 -0
  7. mpflash/mpflash/bootloader/micropython.py +10 -0
  8. mpflash/mpflash/bootloader/touch1200.py +45 -0
  9. mpflash/mpflash/cli_download.py +1 -0
  10. mpflash/mpflash/cli_flash.py +16 -9
  11. mpflash/mpflash/cli_group.py +13 -6
  12. mpflash/mpflash/cli_list.py +6 -2
  13. mpflash/mpflash/cli_main.py +5 -2
  14. mpflash/mpflash/common.py +15 -2
  15. mpflash/mpflash/config.py +27 -1
  16. mpflash/mpflash/download.py +82 -16
  17. mpflash/mpflash/downloaded.py +28 -7
  18. mpflash/mpflash/errors.py +5 -1
  19. mpflash/mpflash/flash.py +10 -27
  20. mpflash/mpflash/flash_uf2.py +4 -6
  21. mpflash/mpflash/flash_uf2_boardid.py +2 -1
  22. mpflash/mpflash/flash_uf2_macos.py +13 -57
  23. mpflash/mpflash/flash_uf2_windows.py +4 -4
  24. mpflash/mpflash/mpboard_id/__init__.py +4 -0
  25. mpflash/mpflash/mpboard_id/board_id.py +19 -3
  26. mpflash/mpflash/mpboard_id/store.py +2 -1
  27. mpflash/mpflash/vendor/click_aliases.py +91 -0
  28. mpflash/poetry.lock +102 -137
  29. mpflash/pyproject.toml +1 -1
  30. stubber/__init__.py +1 -1
  31. stubber/board/createstubs.py +12 -4
  32. stubber/board/createstubs_db.py +4 -5
  33. stubber/board/createstubs_db_min.py +1 -1
  34. stubber/board/createstubs_db_mpy.mpy +0 -0
  35. stubber/board/createstubs_mem.py +4 -5
  36. stubber/board/createstubs_mem_min.py +1 -1
  37. stubber/board/createstubs_mem_mpy.mpy +0 -0
  38. stubber/board/createstubs_min.py +2 -2
  39. stubber/board/createstubs_mpy.mpy +0 -0
  40. stubber/board/modulelist.txt +9 -0
  41. stubber/bulk/mcu_stubber.py +0 -1
  42. stubber/codemod/_partials/__init__.py +0 -2
  43. stubber/publish/candidates.py +7 -28
  44. stubber/publish/enums.py +0 -6
  45. stubber/publish/package.py +15 -46
  46. stubber/publish/publish.py +1 -2
  47. stubber/rst/lookup.py +7 -7
  48. stubber/rst/reader.py +26 -27
  49. stubber/update_module_list.py +2 -26
  50. {micropython_stubber-1.20.2.dist-info → micropython_stubber-1.20.5.dist-info}/LICENSE +0 -0
  51. {micropython_stubber-1.20.2.dist-info → micropython_stubber-1.20.5.dist-info}/entry_points.txt +0 -0
@@ -9,7 +9,7 @@
9
9
  - cross compilation, using mpy-cross,
10
10
  to avoid the compilation step on the micropython device
11
11
 
12
- This variant was generated from createstubs.py by micropython-stubber v1.20.2
12
+ This variant was generated from createstubs.py by micropython-stubber v1.20.5
13
13
  """
14
14
 
15
15
  # Copyright (c) 2019-2024 Jos Verlinde
@@ -34,7 +34,7 @@ try:
34
34
  except ImportError:
35
35
  from ucollections import OrderedDict # type: ignore
36
36
 
37
- __version__ = "v1.20.2"
37
+ __version__ = "v1.20.5"
38
38
  ENOENT = 2
39
39
  _MAX_CLASS_LEVEL = 2 # Max class nesting
40
40
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
@@ -237,7 +237,6 @@ class Stubber:
237
237
  # Start a new file
238
238
  ensure_folder(file_name)
239
239
  with open(file_name, "w") as fp:
240
- # todo: improve header
241
240
  info_ = str(self.info).replace("OrderedDict(", "").replace("})", "}")
242
241
  s = '"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(module_name, self._fwid, info_, __version__)
243
242
  fp.write(s)
@@ -598,10 +597,10 @@ def _info(): # type:() -> dict[str, str]
598
597
  if (
599
598
  info["version"]
600
599
  and info["version"].endswith(".0")
601
- and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.20.2 do not have a micro .0
600
+ and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.20.5 do not have a micro .0
602
601
  and info["version"] <= "1.19.9"
603
602
  ):
604
- # versions from 1.10.0 to 1.20.2 do not have a micro .0
603
+ # versions from 1.10.0 to 1.20.5 do not have a micro .0
605
604
  info["version"] = info["version"][:-2]
606
605
 
607
606
  # spell-checker: disable
@@ -47,7 +47,7 @@ try:from machine import reset
47
47
  except N:pass
48
48
  try:from collections import OrderedDict as g
49
49
  except N:from ucollections import OrderedDict as g
50
- __version__='v1.20.2'
50
+ __version__='v1.20.5'
51
51
  y=2
52
52
  z=2
53
53
  A0=['lib','/lib','/sd/lib','/flash/lib',J]
Binary file
@@ -50,7 +50,7 @@ try:from machine import reset
50
50
  except N:pass
51
51
  try:from collections import OrderedDict as h
52
52
  except N:from ucollections import OrderedDict as h
53
- __version__='v1.20.2'
53
+ __version__='v1.20.5'
54
54
  A0=2
55
55
  A1=2
56
56
  A5=['lib','/lib','/sd/lib','/flash/lib',J]
@@ -287,7 +287,7 @@ def read_path():
287
287
  def j():
288
288
  try:A=bytes('abc',encoding='utf8');B=j.__module__;return H
289
289
  except(k,I):return U
290
- def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_OTA','_asyncio','_boot_fat','_coap','_espnow','_flash_control_OTA','_main_pybytes','_mqtt','_mqtt_core','_msg_handl','_onewire','_periodical_pin','_pybytes','_pybytes_ca','_pybytes_config','_pybytes_config_reader','_pybytes_connection','_pybytes_constants','_pybytes_debug','_pybytes_library','_pybytes_machine_learning','_pybytes_main','_pybytes_protocol','_pybytes_pyconfig','_pybytes_pymesh_config','_rp2','_terminal','_thread','_uasyncio','_urequest','adcfft','aioble/__init__','aioble/central','aioble/client','aioble/core','aioble/device','aioble/l2cap','aioble/peripheral','aioble/security','aioble/server','aioespnow','ak8963','apa102','apa106','argparse','array','asyncio/__init__','asyncio/core','asyncio/event','asyncio/funcs','asyncio/lock','asyncio/stream','binascii','bluetooth','breakout_as7262','breakout_bh1745','breakout_bme280','breakout_bme68x','breakout_bmp280','breakout_dotmatrix','breakout_encoder','breakout_icp10125','breakout_ioexpander','breakout_ltr559','breakout_matrix11x7','breakout_mics6814','breakout_msa301','breakout_paa5100','breakout_pmw3901','breakout_potentiometer','breakout_rgbmatrix5x5','breakout_rtc','breakout_scd41','breakout_sgp30','breakout_trackball','breakout_vl53l5cx','btree','cmath','collections','crypto','cryptolib','curl','deflate','dht','display','display_driver_utils','ds18x20','encoder','errno','esp','esp32','espidf','espnow','ffi','flashbdev','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','hashlib','heapq','hub75','ili9341','ili9XXX','imagetools','inisetup','interstate75','io','jpegdec','json','lcd160cr','lodepng',w,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','math','microWebSocket','microWebSrv','microWebTemplate',b,'mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','ntptime','onewire','os','pcf85063a','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform','pyb',g,'pye','qrcode','queue','random','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','struct',v,'termios','time','tls','tpcalib','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','ucrypto','ucryptolib','uctypes','uerrno','uftpd','uhashlib','uheapq','uio','ujson','ulab','ulab/approx','ulab/compare','ulab/fft','ulab/filter','ulab/linalg','ulab/numerical','ulab/poly','ulab/user','ulab/vector','umachine','umqtt/__init__','umqtt/robust','umqtt/simple','uos','uplatform','uqueue','urandom','ure','urequests','urllib/urequest','uselect','usocket','ussl','ustruct','usys','utelnetserver','utime','utimeq','uwebsocket','uzlib',C,'vfs','websocket','websocket_helper','wipy','writer','xpt2046','ymodem','zephyr','zlib'];F.collect();stubber.create_all_stubs()
290
+ def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_OTA','_asyncio','_boot_fat','_coap','_espnow','_flash_control_OTA','_main_pybytes','_mqtt','_mqtt_core','_msg_handl','_onewire','_periodical_pin','_pybytes','_pybytes_ca','_pybytes_config','_pybytes_config_reader','_pybytes_connection','_pybytes_constants','_pybytes_debug','_pybytes_library','_pybytes_machine_learning','_pybytes_main','_pybytes_protocol','_pybytes_pyconfig','_pybytes_pymesh_config','_rp2','_terminal','_thread','_uasyncio','_urequest','adcfft','aioble/__init__','aioble/central','aioble/client','aioble/core','aioble/device','aioble/l2cap','aioble/peripheral','aioble/security','aioble/server','aioespnow','ak8963','apa102','apa106','argparse','array','asyncio/__init__','asyncio/core','asyncio/event','asyncio/funcs','asyncio/lock','asyncio/stream','binascii','bluetooth','breakout_as7262','breakout_bh1745','breakout_bme280','breakout_bme68x','breakout_bmp280','breakout_dotmatrix','breakout_encoder','breakout_icp10125','breakout_ioexpander','breakout_ltr559','breakout_matrix11x7','breakout_mics6814','breakout_msa301','breakout_paa5100','breakout_pmw3901','breakout_potentiometer','breakout_rgbmatrix5x5','breakout_rtc','breakout_scd41','breakout_sgp30','breakout_trackball','breakout_vl53l5cx','btree','cmath','collections','crypto','cryptolib','curl','deflate','dht','display','display_driver_utils','ds18x20','encoder','errno','esp','esp32','espidf','espnow','ffi','flashbdev','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','hashlib','heapq','hub75','ili9341','ili9XXX','imagetools','inisetup','interstate75','io','jpegdec','js','jsffi','json','lcd160cr','lodepng',w,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','math','microWebSocket','microWebSrv','microWebTemplate',b,'mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','ntptime','onewire','openamp','os','pcf85063a','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform','pyb',g,'pye','qrcode','queue','random','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','struct',v,'termios','time','tls','tpcalib','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','ucrypto','ucryptolib','uctypes','uerrno','uftpd','uhashlib','uheapq','uio','ujson','ulab','ulab/approx','ulab/compare','ulab/fft','ulab/filter','ulab/linalg','ulab/numerical','ulab/poly','ulab/user','ulab/vector','umachine','umqtt/__init__','umqtt/robust','umqtt/simple','uos','uplatform','uqueue','urandom','ure','urequests','urllib/urequest','usb/device','usb/device/cdc','usb/device/hid','usb/device/keyboard','usb/device/midi','usb/device/mouse','uselect','usocket','ussl','ustruct','usys','utelnetserver','utime','utimeq','uwebsocket','uzlib',C,'vfs','websocket','websocket_helper','wipy','writer','xpt2046','ymodem','zephyr','zlib'];F.collect();stubber.create_all_stubs()
291
291
  if __name__=='__main__'or j():
292
292
  if not A4('no_auto_stubber.txt'):
293
293
  try:F.threshold(4*1024);F.enable()
Binary file
@@ -113,6 +113,8 @@ inisetup
113
113
  interstate75
114
114
  io
115
115
  jpegdec
116
+ js
117
+ jsffi
116
118
  json
117
119
  lcd160cr
118
120
  lodepng
@@ -138,6 +140,7 @@ neopixel
138
140
  network
139
141
  ntptime
140
142
  onewire
143
+ openamp
141
144
  os
142
145
  pcf85063a
143
146
  picoexplorer
@@ -216,6 +219,12 @@ urandom
216
219
  ure
217
220
  urequests
218
221
  urllib/urequest
222
+ usb/device
223
+ usb/device/cdc
224
+ usb/device/hid
225
+ usb/device/keyboard
226
+ usb/device/midi
227
+ usb/device/mouse
219
228
  uselect
220
229
  usocket
221
230
  ussl
@@ -23,7 +23,6 @@ from stubber.publish.pathnames import board_folder_name
23
23
  from stubber.publish.publish import build_multiple
24
24
  from stubber.utils.config import CONFIG
25
25
 
26
- # TODO : make this a bit nicer
27
26
  HERE = Path(__file__).parent
28
27
  ###############################################################################################
29
28
  # TODO: promote to cmdline params
@@ -3,7 +3,6 @@ from enum import Enum
3
3
  from pathlib import Path
4
4
  from typing import Iterator, cast
5
5
 
6
- # TODO: this way of accessing the partials is not very robust
7
6
  PARTIALS_DIR = Path(__file__).parent.absolute()
8
7
 
9
8
  PARTIAL_START = "###PARTIAL###"
@@ -18,7 +17,6 @@ def _read_partial(path: Path) -> Iterator[str]:
18
17
  lines = deque(path.read_text(encoding="utf-8").splitlines(keepends=True))
19
18
  _start = False
20
19
  _end = False
21
- # todo: allow processing of files that do not have the markers
22
20
  while True:
23
21
  try:
24
22
  if not _start and (line := lines.popleft()):
@@ -20,7 +20,8 @@ from packaging.version import parse
20
20
  import stubber.basicgit as git
21
21
  from stubber import utils
22
22
  from stubber.publish.defaults import GENERIC, GENERIC_L, GENERIC_U
23
- from stubber.publish.enums import COMBO_STUBS, DOC_STUBS, FIRMWARE_STUBS
23
+
24
+ # from stubber.publish.enums import COMBO_STUBS
24
25
  from stubber.utils.config import CONFIG
25
26
  from stubber.utils.versions import OLDEST_VERSION, SET_PREVIEW, V_PREVIEW, clean_version, micropython_versions
26
27
 
@@ -139,7 +140,7 @@ def frozen_candidates(
139
140
  "version": version,
140
141
  "port": port,
141
142
  "board": GENERIC_L,
142
- "pkg_type": COMBO_STUBS,
143
+ # "pkg_type": COMBO_STUBS,
143
144
  }
144
145
  # if not auto_board:
145
146
  # for board in boards:
@@ -177,7 +178,7 @@ def frozen_candidates(
177
178
  "version": version,
178
179
  "port": port,
179
180
  "board": board,
180
- "pkg_type": COMBO_STUBS,
181
+ # "pkg_type": COMBO_STUBS,
181
182
  }
182
183
 
183
184
 
@@ -189,33 +190,11 @@ def is_auto(thing: Union[None, str, List[str]]):
189
190
  return any(i in ["auto", "all"] for i in thing)
190
191
 
191
192
 
192
- def docstub_candidates(
193
- family: str = "micropython",
194
- versions: Union[str, List[str]] = V_PREVIEW,
195
- path: Path = CONFIG.stub_path,
196
- ):
197
- """
198
- Generate a list of possible documentation stub candidates for the given family and version.
199
-
200
- Note that the folders do not need to exist, with the exception of auto which will scan the stubs folder for versions of docstubs
201
- """
202
- if isinstance(versions, str):
203
- if is_auto(versions): # auto with vprefix ...
204
- versions = list(version_candidates(suffix="docstubs", prefix=family, path=path))
205
- else:
206
- versions = [versions]
207
- versions = [clean_version(v, flat=True) for v in versions]
208
-
209
- for version in versions:
210
- yield {"family": family, "version": version, "pkg_type": DOC_STUBS}
211
-
212
-
213
193
  def board_candidates(
214
194
  family: str = "micropython",
215
195
  versions: Union[str, List[str]] = V_PREVIEW,
216
196
  *,
217
197
  mpy_path: Path = CONFIG.mpy_path,
218
- pt: str = FIRMWARE_STUBS,
219
198
  ):
220
199
  """
221
200
  generate a list of possible board stub candidates for the given family and version.
@@ -236,7 +215,9 @@ def board_candidates(
236
215
  else:
237
216
  r = git.checkout_tag(repo=mpy_path, tag=version)
238
217
  if not r:
239
- log.warning(f"Incorrect version: {version} or did you forget to run `stubber clone` to get the micropython repo?")
218
+ log.warning(
219
+ f"Incorrect version: {version} or did you forget to run `stubber clone` to get the micropython repo?"
220
+ )
240
221
  return []
241
222
  ports = list_micropython_ports(family=family, mpy_path=mpy_path)
242
223
  for port in ports:
@@ -246,7 +227,6 @@ def board_candidates(
246
227
  "version": version,
247
228
  "port": port,
248
229
  "board": GENERIC_U,
249
- "pkg_type": pt,
250
230
  }
251
231
  for board in list_micropython_port_boards(family=family, mpy_path=mpy_path, port=port):
252
232
  if board not in GENERIC:
@@ -255,7 +235,6 @@ def board_candidates(
255
235
  "version": version,
256
236
  "port": port,
257
237
  "board": board,
258
- "pkg_type": pt,
259
238
  }
260
239
 
261
240
 
stubber/publish/enums.py CHANGED
@@ -22,9 +22,3 @@ class StubSource(str, Enum):
22
22
  # Always force string values
23
23
  return self.value
24
24
 
25
-
26
- ALL_TYPES = ["combo", "doc", "core", "firmware"]
27
- COMBO_STUBS = ALL_TYPES[0]
28
- DOC_STUBS = ALL_TYPES[1]
29
- CORE_STUBS = ALL_TYPES[2]
30
- FIRMWARE_STUBS = ALL_TYPES[3]
@@ -2,6 +2,7 @@
2
2
  prepare a set of stub files for publishing to PyPi
3
3
 
4
4
  """
5
+
5
6
  import sys
6
7
  from pathlib import Path
7
8
  from typing import Dict, Union
@@ -11,7 +12,7 @@ from packaging.version import parse
11
12
  from pysondb import PysonDB
12
13
 
13
14
  from stubber.publish.defaults import GENERIC, GENERIC_L, default_board
14
- from stubber.publish.enums import COMBO_STUBS, CORE_STUBS, DOC_STUBS, StubSource
15
+ from stubber.publish.enums import StubSource
15
16
  from stubber.publish.stubpackage import StubPackage, StubSources
16
17
  from stubber.utils.config import CONFIG
17
18
  from stubber.utils.versions import clean_version
@@ -21,27 +22,12 @@ log.remove()
21
22
  log.add(sys.stderr, level="INFO", backtrace=True, diagnose=True)
22
23
 
23
24
 
24
- def package_name(
25
- pkg_type: str, *, port: str = "", board: str = "", family: str = "micropython", **kwargs
26
- ) -> str:
25
+ def package_name(*, port: str = "", board: str = "", family: str = "micropython", **kwargs) -> str:
27
26
  "generate a package name for the given package type"
28
- if pkg_type == COMBO_STUBS:
29
- # # {family}-{port}-{board}-stubs
30
- name = f"{family}-{port}-{board}-stubs".lower()
31
- name = name.replace("-generic-stubs", "-stubs")
32
- # Use explicit generic_ names for the stubs
33
- # name = name.replace("-generic_", "-") # @GENERIC Prefix
34
- return name
35
- elif pkg_type == DOC_STUBS:
36
- return f"{family}-doc-stubs".lower()
37
- elif pkg_type == CORE_STUBS:
38
- return f"{family}-core-stubs".lower()
39
- # # {family}-{port}-{board}-{type}-stubs
40
- name = f"{family}-{port}-{board}-{pkg_type}-stubs".lower()
27
+ # # {family}-{port}[-{board}[-{variant}]]-stubs
28
+ name = f"{family}-{port}-{board}-stubs".lower()
29
+ name = name.replace("-generic-stubs", "-stubs")
41
30
  # Use explicit generic_ names for the stubs
42
- # # remove -generic- from the name
43
- # name = name.replace(f"-generic-{pkg_type}-stubs", f"-{pkg_type}-stubs")
44
- # # remove -genetic_ from the name
45
31
  # name = name.replace("-generic_", "-") # @GENERIC Prefix
46
32
  return name
47
33
 
@@ -49,14 +35,13 @@ def package_name(
49
35
  def get_package(
50
36
  db: PysonDB,
51
37
  *,
52
- pkg_type: str,
53
38
  version: str,
54
39
  port: str,
55
40
  board: str = GENERIC_L,
56
41
  family: str = "micropython",
57
42
  ) -> StubPackage:
58
43
  """Get the package from the database or create a new one if it does not exist."""
59
- pkg_name = package_name(pkg_type, port=port, board=board, family=family)
44
+ pkg_name = package_name(port=port, board=board, family=family)
60
45
  version = clean_version(version, drop_v=True)
61
46
  if package_info := get_package_info(
62
47
  db,
@@ -74,13 +59,10 @@ def get_package(
74
59
  port=port,
75
60
  board=board,
76
61
  family=family,
77
- pkg_type=pkg_type,
78
62
  )
79
63
 
80
64
 
81
- def get_package_info(
82
- db: PysonDB, pub_path: Path, *, pkg_name: str, mpy_version: str
83
- ) -> Union[Dict, None]:
65
+ def get_package_info(db: PysonDB, pub_path: Path, *, pkg_name: str, mpy_version: str) -> Union[Dict, None]:
84
66
  """
85
67
  get a package's record from the json db if it can be found
86
68
  matches om the package name and version
@@ -88,9 +70,7 @@ def get_package_info(
88
70
  mpy_version: micropython/firmware version (1.18)
89
71
  """
90
72
  # find in the database
91
- recs = db.get_by_query(
92
- query=lambda x: x["mpy_version"] == mpy_version and x["name"] == pkg_name
93
- )
73
+ recs = db.get_by_query(query=lambda x: x["mpy_version"] == mpy_version and x["name"] == pkg_name)
94
74
  # dict to list
95
75
  recs = [{"id": key, "data": recs[key]} for key in recs]
96
76
  # sort
@@ -108,32 +88,21 @@ def create_package(
108
88
  pkg_name: str,
109
89
  mpy_version: str,
110
90
  *,
111
- port: str = "",
91
+ port: str,
112
92
  board: str = "",
113
93
  family: str = "micropython",
114
- pkg_type: str = COMBO_STUBS,
94
+ # pkg_type: str = COMBO_STUBS,
115
95
  ) -> StubPackage: # sourcery skip: merge-duplicate-blocks, remove-redundant-if
116
96
  """
117
97
  create and initialize a package with the correct sources
118
98
  """
119
99
  ver_flat = clean_version(mpy_version, flat=True)
120
100
  stubs: StubSources = []
121
- if pkg_type == COMBO_STUBS:
122
- assert port != "", "port must be specified for combo stubs"
123
- stubs = combo_sources(family, port, board, ver_flat)
124
- elif pkg_type == DOC_STUBS:
125
- stubs = [
126
- (
127
- StubSource.DOC,
128
- Path(f"{family}-{ver_flat}-docstubs"),
129
- ),
130
- ]
131
- elif pkg_type == CORE_STUBS:
132
- # TODO add core stubs
133
- raise NotImplementedError(type)
134
- else:
135
- raise NotImplementedError(type)
101
+ # if pkg_type != COMBO_STUBS:
102
+ # raise ValueError("Not Supported")
136
103
 
104
+ assert port != "", "port must be specified for combo stubs"
105
+ stubs = combo_sources(family, port, board, ver_flat)
137
106
  return StubPackage(pkg_name, port=port, board=board, version=mpy_version, stubs=stubs)
138
107
 
139
108
 
@@ -11,7 +11,6 @@ from loguru import logger as log
11
11
  from stubber.publish.candidates import board_candidates, filter_list
12
12
  from stubber.publish.database import get_database
13
13
  from stubber.publish.defaults import GENERIC_U
14
- from stubber.publish.enums import COMBO_STUBS
15
14
  from stubber.publish.package import get_package
16
15
  from stubber.utils.config import CONFIG
17
16
  from stubber.utils.versions import V_PREVIEW
@@ -110,7 +109,7 @@ def build_worklist(
110
109
  if family != "micropython":
111
110
  return []
112
111
  # get all the candidates
113
- worklist = list(board_candidates(family=family, versions=versions, pt=COMBO_STUBS))
112
+ worklist = list(board_candidates(family=family, versions=versions))
114
113
  worklist = filter_list(worklist, ports, boards)
115
114
 
116
115
  for b in boards:
stubber/rst/lookup.py CHANGED
@@ -254,7 +254,7 @@ PARAM_FIXES = [
254
254
  Fix("\\*", "*"), # change weirdly written wildcards \* --> *
255
255
  Fix(r"\**", "*"), # change weirdly written wildcards \* --> *
256
256
  Fix(r"/*", "*"), # change weirdly written wildcards \* --> *
257
- # ("**", "*"), # change weirdly written wildcards \* --> *
257
+ Fix(r"/)", ")"), # strange terminator in machine.USBDevice `USBDevice.active(self, [value] /)`
258
258
  Fix("'param'", "param"), # loose notation in documentation
259
259
  # illegal keywords
260
260
  Fix(
@@ -484,17 +484,17 @@ PARAM_FIXES = [
484
484
  # List of classes and their parent classes that should be added to the class definition
485
485
  CHILD_PARENT_CLASS = {
486
486
  # machine
487
- # SoftSPI is defined before SPI, so baseclass is not yet available - but in a .pyi that is OK
488
- "SoftSPI": "SPI",
487
+ # SoftSPI is defined before SPI, so baseclass is not yet available - but in a .pyi that is OK
488
+ "SoftSPI": "SPI",
489
489
  "SoftI2C": "I2C",
490
490
  "Switch": "Pin",
491
491
  "Signal": "Pin",
492
492
  # uio # unclear regarding deprecation in python 3.12
493
493
  # "IOBase": "IO", # DOCME not in documentation
494
- "TextIOWrapper": "IO", # "TextIOBase, TextIO", # based on Stdlib
495
- "FileIO": "IO", # "RawIOBase, BinaryIO", # based on Stdlib
496
- "StringIO": "IO", # "BufferedIOBase, BinaryIO", # based on Stdlib
497
- "BytesIO": "IO", # "BufferedIOBase, BinaryIO", # based on Stdlib
494
+ "TextIOWrapper": "IO", # "TextIOBase, TextIO", # based on Stdlib
495
+ "FileIO": "IO", # "RawIOBase, BinaryIO", # based on Stdlib
496
+ "StringIO": "IO", # "BufferedIOBase, BinaryIO", # based on Stdlib
497
+ "BytesIO": "IO", # "BufferedIOBase, BinaryIO", # based on Stdlib
498
498
  "BufferedWriter": "IOBase", # DOCME: not in documentation # "BufferedWriter": "BufferedIOBase", # based on Stdlib
499
499
  # uzlib
500
500
  # "DecompIO": "IO", # https://docs.python.org/3/library/typing.html#other-concrete-types
stubber/rst/reader.py CHANGED
@@ -63,7 +63,6 @@ Note: black on python 3.7 does not like some function defs
63
63
 
64
64
  """
65
65
 
66
-
67
66
  import re
68
67
  from pathlib import Path
69
68
  from typing import List, Optional, Tuple
@@ -150,11 +149,7 @@ class FileReadWriter:
150
149
  """
151
150
  append = 0
152
151
  newline = self.rst_text[self.line_no]
153
- while (
154
- not self.is_balanced(newline)
155
- and self.line_no >= 0
156
- and (self.line_no + append + 1) <= self.max_line
157
- ):
152
+ while not self.is_balanced(newline) and self.line_no >= 0 and (self.line_no + append + 1) <= self.max_line:
158
153
  append += 1
159
154
  # concat the lines
160
155
  newline += self.rst_text[self.line_no + append]
@@ -225,9 +220,7 @@ class RSTReader(FileReadWriter):
225
220
  "stop at heading"
226
221
  u_line = self.rst_text[min(self.line_no + 1, self.max_line - 1)].rstrip()
227
222
  # Heading ---, ==, ~~~
228
- underlined = (
229
- u_line.startswith("---") or u_line.startswith("===") or u_line.startswith("~~~")
230
- )
223
+ underlined = u_line.startswith("---") or u_line.startswith("===") or u_line.startswith("~~~")
231
224
  if underlined and self.line_no > 0:
232
225
  # check if previous line is a heading
233
226
  line = self.rst_text[self.line_no].strip()
@@ -374,12 +367,8 @@ class RSTParser(RSTReader):
374
367
  target = ".py" # py/pyi
375
368
  # TODO: Move to lookup.py
376
369
  PARAM_RE_FIXES = [
377
- Fix(
378
- r"\[angle, time=0\]", "[angle], time=0", is_re=True
379
- ), # fix: method:: Servo.angle([angle, time=0])
380
- Fix(
381
- r"\[speed, time=0\]", "[speed], time=0", is_re=True
382
- ), # fix: .. method:: Servo.speed([speed, time=0])
370
+ Fix(r"\[angle, time=0\]", "[angle], time=0", is_re=True), # fix: method:: Servo.angle([angle, time=0])
371
+ Fix(r"\[speed, time=0\]", "[speed], time=0", is_re=True), # fix: .. method:: Servo.speed([speed, time=0])
383
372
  Fix(
384
373
  r"\[service_id, key=None, \*, \.\.\.\]", "[service_id], [key], *, ...", is_re=True
385
374
  ), # fix: network - AbstractNIC.connect
@@ -446,9 +435,7 @@ class RSTParser(RSTReader):
446
435
  def apply_fix(fix: Fix, params: str, name: str = ""):
447
436
  if fix.name and fix.name != name:
448
437
  return params
449
- return (
450
- re.sub(fix.from_, fix.to, params) if fix.is_re else params.replace(fix.from_, fix.to)
451
- )
438
+ return re.sub(fix.from_, fix.to, params) if fix.is_re else params.replace(fix.from_, fix.to)
452
439
 
453
440
  def create_update_class(self, name: str, params: str, docstr: List[str]):
454
441
  # a bit of a hack: assume no classes in classes or functions in function
@@ -509,12 +496,10 @@ class RSTParser(RSTReader):
509
496
  if "nightly" in self.source_tag:
510
497
  version = V_PREVIEW
511
498
  else:
512
- version = self.source_tag.replace(
513
- "_", "."
514
- ) # TODO Use clean_version(self.source_tag)
515
- docstr[
516
- 0
517
- ] = f"{docstr[0]}.\n\nMicroPython module: https://docs.micropython.org/en/{version}/library/{module_name}.html"
499
+ version = self.source_tag.replace("_", ".") # TODO Use clean_version(self.source_tag)
500
+ docstr[0] = (
501
+ f"{docstr[0]}.\n\nMicroPython module: https://docs.micropython.org/en/{version}/library/{module_name}.html"
502
+ )
518
503
 
519
504
  self.output_dict.name = module_name
520
505
  self.output_dict.add_comment(f"# source version: {self.source_tag}")
@@ -546,9 +531,7 @@ class RSTParser(RSTReader):
546
531
 
547
532
  for this_function in function_names:
548
533
  # Parse return type from docstring
549
- ret_type = return_type_from_context(
550
- docstring=docstr, signature=this_function, module=self.current_module
551
- )
534
+ ret_type = return_type_from_context(docstring=docstr, signature=this_function, module=self.current_module)
552
535
 
553
536
  # defaults
554
537
  name = params = ""
@@ -663,6 +646,8 @@ class RSTParser(RSTReader):
663
646
  # - staticmethod ( <params>) -> <ret_type>:
664
647
  # - all other methods (self, <params>) -> <ret_type>:
665
648
  if name == "__init__":
649
+ # avoid params starting with `self ,`
650
+ params = self.lstrip_self(params)
666
651
  method = FunctionSourceDict(
667
652
  name=f"def {name}",
668
653
  indent=parent_class.indent + 4,
@@ -688,6 +673,8 @@ class RSTParser(RSTReader):
688
673
  is_async=is_async,
689
674
  )
690
675
  else: # just plain method
676
+ # avoid params starting with `self ,`
677
+ params = self.lstrip_self(params)
691
678
  method = FunctionSourceDict(
692
679
  name=f"def {name}",
693
680
  indent=parent_class.indent + 4,
@@ -695,8 +682,20 @@ class RSTParser(RSTReader):
695
682
  docstr=docstr,
696
683
  is_async=is_async,
697
684
  )
685
+
698
686
  parent_class += method
699
687
 
688
+ def lstrip_self(self, params):
689
+ """
690
+ To avoid duplicate selfs,
691
+ Remove `self,` from the start of the parameters
692
+ """
693
+ if params.startswith("self,"):
694
+ params = params[6:]
695
+ elif params.startswith("self ,"):
696
+ params = params[7:]
697
+ return params
698
+
700
699
  def parse_exception(self):
701
700
  log.trace(f"# {self.line.rstrip()}")
702
701
  name = self.line.split(SEPERATOR)[1].strip()
@@ -10,10 +10,6 @@ for this :
10
10
  - write updates to:
11
11
  - board/modulelist.txt
12
12
  - board/createstubs.py
13
-
14
- - TODO: remove the frozen modules from this list
15
- - TODO: bump patch number if there are actual changes
16
-
17
13
  """
18
14
 
19
15
  from pathlib import Path
@@ -32,7 +28,7 @@ def read_modules(path: Optional[Path] = None) -> Set[str]:
32
28
  """
33
29
  path = Path(path or "./data")
34
30
  assert path
35
- all_modules = set()
31
+ all_modules: Set[str] = set()
36
32
  for file in path.glob("*.txt"):
37
33
  log.debug(f"processing: {file.name}")
38
34
  with file.open("r") as f:
@@ -45,27 +41,7 @@ def read_modules(path: Optional[Path] = None) -> Set[str]:
45
41
  file_mods = [m for m in file_mods if not m.endswith("_test")]
46
42
  all_modules = set(all_modules | set(file_mods))
47
43
  log.trace(">" * 40)
48
-
49
- return all_modules
50
-
51
-
52
- # def wrapped(modules: Union[Set, List]) -> str:
53
- # "wrap code line at spaces"
54
- # long_line = str(modules)
55
- # _wrapped = " self.modules = "
56
- # IDENT = len(_wrapped)
57
- # MAX_WIDTH = 135
58
-
59
- # # find seperator
60
- # while len(long_line) > MAX_WIDTH:
61
- # p1 = long_line.find("', ", MAX_WIDTH)
62
- # # drop space
63
- # p1 += 3
64
- # short = long_line[0 : p1 - 1]
65
- # _wrapped += short + "\n" + " " * IDENT
66
- # long_line = long_line[p1 - 1 :]
67
- # _wrapped += long_line
68
- # return _wrapped
44
+ return {m.replace(".", "/") for m in all_modules}
69
45
 
70
46
 
71
47
  def update_module_list():