micropython-stubber 1.23.1__py3-none-any.whl → 1.23.1.post1__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 (61) hide show
  1. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.1.post1.dist-info}/METADATA +30 -13
  2. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.1.post1.dist-info}/RECORD +60 -60
  3. micropython_stubber-1.23.1.post1.dist-info/entry_points.txt +5 -0
  4. mpflash/README.md +26 -0
  5. mpflash/mpflash/cli_download.py +1 -1
  6. mpflash/mpflash/cli_flash.py +11 -14
  7. mpflash/mpflash/cli_list.py +8 -2
  8. mpflash/mpflash/common.py +2 -1
  9. mpflash/mpflash/connected.py +2 -3
  10. mpflash/mpflash/list.py +20 -13
  11. mpflash/mpflash/mpremoteboard/__init__.py +50 -6
  12. mpflash/pyproject.toml +1 -1
  13. stubber/bulk/mcu_stubber.py +28 -45
  14. stubber/codemod/enrich.py +1 -1
  15. stubber/codemod/merge_docstub.py +1 -1
  16. stubber/commands/build_cmd.py +1 -1
  17. stubber/commands/cli.py +5 -11
  18. stubber/commands/clone_cmd.py +1 -1
  19. stubber/commands/config_cmd.py +1 -1
  20. stubber/commands/enrich_folder_cmd.py +1 -1
  21. stubber/commands/get_core_cmd.py +1 -1
  22. stubber/commands/get_docstubs_cmd.py +5 -2
  23. stubber/commands/get_frozen_cmd.py +5 -2
  24. stubber/commands/get_mcu_cmd.py +52 -11
  25. stubber/commands/merge_cmd.py +1 -1
  26. stubber/commands/publish_cmd.py +1 -1
  27. stubber/commands/stub_cmd.py +1 -1
  28. stubber/commands/variants_cmd.py +1 -1
  29. stubber/downloader.py +2 -1
  30. stubber/freeze/common.py +7 -3
  31. stubber/freeze/freeze_folder.py +2 -2
  32. stubber/freeze/freeze_manifest_2.py +19 -6
  33. stubber/freeze/get_frozen.py +7 -3
  34. stubber/get_cpython.py +15 -4
  35. stubber/minify.py +7 -3
  36. stubber/publish/candidates.py +26 -7
  37. stubber/publish/merge_docstubs.py +4 -2
  38. stubber/publish/missing_class_methods.py +4 -2
  39. stubber/publish/package.py +7 -3
  40. stubber/publish/pathnames.py +1 -1
  41. stubber/publish/publish.py +1 -1
  42. stubber/publish/pypi.py +6 -2
  43. stubber/publish/stubpackage.py +40 -16
  44. stubber/rst/classsort.py +2 -1
  45. stubber/rst/lookup.py +1 -0
  46. stubber/rst/reader.py +7 -7
  47. stubber/rst/report_return.py +12 -4
  48. stubber/rst/rst_utils.py +2 -1
  49. stubber/stubs_from_docs.py +1 -1
  50. stubber/tools/manifestfile.py +1 -1
  51. stubber/update_fallback.py +1 -1
  52. stubber/update_module_list.py +1 -1
  53. stubber/utils/config.py +19 -7
  54. stubber/utils/post.py +2 -1
  55. stubber/utils/repos.py +9 -3
  56. stubber/utils/stubmaker.py +1 -1
  57. stubber/utils/typed_config_toml.py +5 -2
  58. stubber/variants.py +1 -1
  59. micropython_stubber-1.23.1.dist-info/entry_points.txt +0 -3
  60. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.1.post1.dist-info}/LICENSE +0 -0
  61. {micropython_stubber-1.23.1.dist-info → micropython_stubber-1.23.1.post1.dist-info}/WHEEL +0 -0
@@ -22,7 +22,7 @@ import shutil # start moving from os & glob to pathlib
22
22
  from pathlib import Path
23
23
  from typing import List, Optional
24
24
 
25
- from loguru import logger as log
25
+ from mpflash.logger import log
26
26
  from packaging.version import Version
27
27
 
28
28
  from mpflash.versions import SET_PREVIEW, V_PREVIEW
@@ -83,7 +83,9 @@ def freeze_any(
83
83
  frozen_stub_path = get_fsp(version, stub_folder)
84
84
  log.debug("MicroPython v1.11, older or other")
85
85
  # others
86
- modules = freeze_folders(frozen_stub_path.as_posix(), mpy_path.as_posix(), mpy_lib_path.as_posix(), version)
86
+ modules = freeze_folders(
87
+ frozen_stub_path.as_posix(), mpy_path.as_posix(), mpy_lib_path.as_posix(), version
88
+ )
87
89
  count = len(modules)
88
90
  else:
89
91
  # get the current checked out version
@@ -120,7 +122,9 @@ def freeze_any(
120
122
 
121
123
  def get_fsp(version: str, stub_folder: Optional[Path] = None) -> Path:
122
124
  if not stub_folder:
123
- frozen_stub_path = CONFIG.stub_path / f"{FAMILY}-{utils.clean_version(version, flat=True)}-frozen"
125
+ frozen_stub_path = (
126
+ CONFIG.stub_path / f"{FAMILY}-{utils.clean_version(version, flat=True)}-frozen"
127
+ )
124
128
  frozen_stub_path = frozen_stub_path.absolute()
125
129
  else:
126
130
  frozen_stub_path: Path = Path(stub_folder).absolute()
stubber/get_cpython.py CHANGED
@@ -2,6 +2,7 @@
2
2
  Download or update the MicroPython compatibility modules from pycopy and stores them in the all_stubs folder
3
3
  The all_stubs folder should be mapped/symlinked to the micropython_stubs/stubs repo/folder
4
4
  """
5
+
5
6
  # pragma: no cover
6
7
  import json
7
8
  import os
@@ -12,7 +13,7 @@ import tempfile
12
13
  from pathlib import Path
13
14
  from typing import Optional, Union
14
15
 
15
- from loguru import logger as log
16
+ from mpflash.logger import log
16
17
 
17
18
  from . import __version__
18
19
 
@@ -22,7 +23,9 @@ from .utils.config import CONFIG
22
23
  # # log = logging.getLogger(__name__)
23
24
 
24
25
 
25
- def get_core(requirements: str, stub_path: Optional[Union[str, Path]] = None, family: str = "core"):
26
+ def get_core(
27
+ requirements: str, stub_path: Optional[Union[str, Path]] = None, family: str = "core"
28
+ ):
26
29
  "Download MicroPython compatibility modules"
27
30
  if not stub_path:
28
31
  stub_path = CONFIG.stub_path / "cpython-core" # pragma: no cover
@@ -71,7 +74,9 @@ def get_core(requirements: str, stub_path: Optional[Union[str, Path]] = None, fa
71
74
 
72
75
  except OSError as err: # pragma: no cover
73
76
  log.error(
74
- "An error occurred while trying to run pip to download the MicroPython compatibility modules from PyPi: {}".format(err)
77
+ "An error occurred while trying to run pip to download the MicroPython compatibility modules from PyPi: {}".format(
78
+ err
79
+ )
75
80
  )
76
81
 
77
82
  # copy *.py files in build folder to stub_path
@@ -86,7 +91,13 @@ def get_core(requirements: str, stub_path: Optional[Union[str, Path]] = None, fa
86
91
  log.exception(err)
87
92
 
88
93
  # build modules.json
89
- mod_manifest = utils.manifest(family="cpython-core", port=family, version=__version__, stubtype="core", platform="cpython")
94
+ mod_manifest = utils.manifest(
95
+ family="cpython-core",
96
+ port=family,
97
+ version=__version__,
98
+ stubtype="core",
99
+ platform="cpython",
100
+ )
90
101
  mod_manifest["modules"] += modlist
91
102
 
92
103
  if mod_manifest and len(modlist):
stubber/minify.py CHANGED
@@ -16,7 +16,7 @@ try:
16
16
  except ImportError:
17
17
  python_minifier = None
18
18
 
19
- from loguru import logger as log
19
+ from mpflash.logger import log
20
20
 
21
21
  from mpflash.versions import SET_PREVIEW, V_PREVIEW
22
22
 
@@ -205,7 +205,9 @@ def minify_script(source_script: StubSource, keep_report: bool = True, diff: boo
205
205
  elif isinstance(source_script, str): # type: ignore
206
206
  source_content = source_script
207
207
  else:
208
- raise TypeError(f"source_script must be str, Path, or file-like object, not {type(source_script)}")
208
+ raise TypeError(
209
+ f"source_script must be str, Path, or file-like object, not {type(source_script)}"
210
+ )
209
211
 
210
212
  if not source_content:
211
213
  raise ValueError("No source content")
@@ -400,7 +402,9 @@ def pipx_mpy_cross(version: str, source_file, _target):
400
402
  # Add params
401
403
  cmd += ["-O2", str(source_file), "-o", str(_target), "-s", "createstubs.py"]
402
404
  log.trace(" ".join(cmd))
403
- result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8") # Specify the encoding
405
+ result = subprocess.run(
406
+ cmd, capture_output=True, text=True, encoding="utf-8"
407
+ ) # Specify the encoding
404
408
  return result
405
409
 
406
410
 
@@ -14,11 +14,17 @@ import re
14
14
  from pathlib import Path
15
15
  from typing import Any, Dict, Generator, List, Optional, Union
16
16
 
17
- from loguru import logger as log
17
+ from mpflash.logger import log
18
18
  from packaging.version import parse
19
19
 
20
20
  import mpflash.basicgit as git
21
- from mpflash.versions import OLDEST_VERSION, SET_PREVIEW, V_PREVIEW, clean_version, micropython_versions
21
+ from mpflash.versions import (
22
+ OLDEST_VERSION,
23
+ SET_PREVIEW,
24
+ V_PREVIEW,
25
+ clean_version,
26
+ micropython_versions,
27
+ )
22
28
  from stubber import utils
23
29
  from stubber.publish.defaults import GENERIC, GENERIC_L, GENERIC_U
24
30
 
@@ -108,7 +114,9 @@ def frozen_candidates(
108
114
  auto_port = is_auto(ports)
109
115
  auto_board = is_auto(boards)
110
116
  if is_auto(versions):
111
- versions = list(version_candidates(suffix="frozen", prefix=family, path=path)) + [V_PREVIEW]
117
+ versions = list(version_candidates(suffix="frozen", prefix=family, path=path)) + [
118
+ V_PREVIEW
119
+ ]
112
120
  else:
113
121
  versions = [versions] if isinstance(versions, str) else versions
114
122
 
@@ -126,7 +134,9 @@ def frozen_candidates(
126
134
  # lookup the (frozen) micropython ports
127
135
  ports = list_frozen_ports(family, version, path=path)
128
136
  else:
129
- raise NotImplementedError(f"auto ports not implemented for family {family}") # pragma: no cover
137
+ raise NotImplementedError(
138
+ f"auto ports not implemented for family {family}"
139
+ ) # pragma: no cover
130
140
  # elif family == "pycom":
131
141
  # ports = ["esp32"]
132
142
  # elif family == "lobo":
@@ -159,7 +169,9 @@ def frozen_candidates(
159
169
 
160
170
  else:
161
171
  # raise NotImplementedError(f"auto boards not implemented for family {family}") # pragma: no cover
162
- raise NotImplementedError(f"auto boards not implemented for family {family}") # pragma: no cover
172
+ raise NotImplementedError(
173
+ f"auto boards not implemented for family {family}"
174
+ ) # pragma: no cover
163
175
  # elif family == "pycom":
164
176
  # boards = ["wipy", "lopy", "gpy", "fipy"]
165
177
  # ---------------------------------------------------------------------------
@@ -215,7 +227,9 @@ def board_candidates(
215
227
  else:
216
228
  r = git.checkout_tag(repo=mpy_path, tag=version)
217
229
  if not r:
218
- log.warning(f"Incorrect version: {version} or did you forget to run `stubber clone` to get the micropython repo?")
230
+ log.warning(
231
+ f"Incorrect version: {version} or did you forget to run `stubber clone` to get the micropython repo?"
232
+ )
219
233
  return []
220
234
  ports = list_micropython_ports(family=family, mpy_path=mpy_path)
221
235
  for port in ports:
@@ -252,5 +266,10 @@ def filter_list(
252
266
  worklist = [i for i in worklist if i["port"].lower() in ports_]
253
267
  if boards and not is_auto(boards):
254
268
  boards_ = [i.lower() for i in boards]
255
- worklist = [i for i in worklist if i["board"].lower() in boards_ or i["board"].lower().replace("generic_", "") in boards_]
269
+ worklist = [
270
+ i
271
+ for i in worklist
272
+ if i["board"].lower() in boards_
273
+ or i["board"].lower().replace("generic_", "") in boards_
274
+ ]
256
275
  return worklist
@@ -6,7 +6,7 @@ import shutil
6
6
  from pathlib import Path
7
7
  from typing import List, Optional, Union
8
8
 
9
- from loguru import logger as log
9
+ from mpflash.logger import log
10
10
 
11
11
  from stubber.codemod.enrich import enrich_folder
12
12
  from stubber.publish.candidates import board_candidates, filter_list
@@ -49,7 +49,9 @@ def merge_all_docstubs(
49
49
  for candidate in candidates:
50
50
  # use the default board for the port
51
51
  if candidate["board"] in GENERIC:
52
- candidate["board"] = default_board(port=candidate["port"], version=candidate["version"])
52
+ candidate["board"] = default_board(
53
+ port=candidate["port"], version=candidate["version"]
54
+ )
53
55
  # check if we have MCU stubs of this version and port
54
56
  doc_path = CONFIG.stub_path / f"{get_base(candidate)}-docstubs"
55
57
  # src and dest paths
@@ -6,7 +6,7 @@ Add missing methods to classes in the stubs that are documented in the docstubs
6
6
  from pathlib import Path
7
7
 
8
8
  import libcst as cst
9
- from loguru import logger as log
9
+ from mpflash.logger import log
10
10
 
11
11
  from mpflash.versions import clean_version
12
12
  from stubber.codemod.add_method import CallAdder, CallFinder
@@ -23,7 +23,9 @@ def add_machine_pin_call(merged_path: Path, version: str):
23
23
  # and to avoid having to parse the file twice
24
24
 
25
25
  # first find the __call__ method in the default stubs
26
- mod_path = CONFIG.stub_path / f"micropython-{clean_version(version, flat=True)}-docstubs/machine.pyi"
26
+ mod_path = (
27
+ CONFIG.stub_path / f"micropython-{clean_version(version, flat=True)}-docstubs/machine.pyi"
28
+ )
27
29
  if not mod_path.exists():
28
30
  log.error(f"no docstubs found for {version}")
29
31
  return False
@@ -7,7 +7,7 @@ import sys
7
7
  from pathlib import Path
8
8
  from typing import Dict, Union
9
9
 
10
- from loguru import logger as log
10
+ from mpflash.logger import log
11
11
  from packaging.version import parse
12
12
  from pysondb import PysonDB
13
13
 
@@ -62,7 +62,9 @@ def get_package(
62
62
  )
63
63
 
64
64
 
65
- def get_package_info(db: PysonDB, pub_path: Path, *, pkg_name: str, mpy_version: str) -> Union[Dict, None]:
65
+ def get_package_info(
66
+ db: PysonDB, pub_path: Path, *, pkg_name: str, mpy_version: str
67
+ ) -> Union[Dict, None]:
66
68
  """
67
69
  get a package's record from the json db if it can be found
68
70
  matches om the package name and version
@@ -70,7 +72,9 @@ def get_package_info(db: PysonDB, pub_path: Path, *, pkg_name: str, mpy_version:
70
72
  mpy_version: micropython/firmware version (1.18)
71
73
  """
72
74
  # find in the database
73
- recs = db.get_by_query(query=lambda x: x["mpy_version"] == mpy_version and x["name"] == pkg_name)
75
+ recs = db.get_by_query(
76
+ query=lambda x: x["mpy_version"] == mpy_version and x["name"] == pkg_name
77
+ )
74
78
  # dict to list
75
79
  recs = [{"id": key, "data": recs[key]} for key in recs]
76
80
  # sort
@@ -6,7 +6,7 @@ Helper functions to deal with path names and filenames for the folders in the st
6
6
  from pathlib import Path
7
7
  from typing import Dict, Optional
8
8
 
9
- from loguru import logger as log
9
+ from mpflash.logger import log
10
10
 
11
11
  from mpflash.versions import V_PREVIEW, clean_version
12
12
  from stubber.publish.defaults import default_board
@@ -6,7 +6,7 @@ prepare a set of stub files for publishing to PyPi
6
6
 
7
7
  from typing import Any, Dict, List, Optional, Union
8
8
 
9
- from loguru import logger as log
9
+ from mpflash.logger import log
10
10
 
11
11
  from mpflash.versions import V_PREVIEW
12
12
  from stubber.publish.candidates import board_candidates, filter_list
stubber/publish/pypi.py CHANGED
@@ -7,7 +7,7 @@ from typing import Optional
7
7
 
8
8
  from packaging.version import Version, parse
9
9
  from pypi_simple import PyPISimple, NoSuchProjectError
10
- from loguru import logger as log
10
+ from mpflash.logger import log
11
11
 
12
12
 
13
13
  def get_pypi_versions(package_name: str, base: Optional[Version] = None, production: bool = True):
@@ -28,7 +28,11 @@ def get_pypi_versions(package_name: str, base: Optional[Version] = None, product
28
28
  if not package_info:
29
29
  return []
30
30
 
31
- versions = [parse(pkg.version) for pkg in package_info.packages if pkg.package_type == "wheel" and pkg.version]
31
+ versions = [
32
+ parse(pkg.version)
33
+ for pkg in package_info.packages
34
+ if pkg.package_type == "wheel" and pkg.version
35
+ ]
32
36
  # print(versions)
33
37
 
34
38
  if base:
@@ -5,6 +5,7 @@ import json
5
5
  import shutil
6
6
  import subprocess
7
7
  from pathlib import Path
8
+ import sys
8
9
  from typing import Any, Dict, List, Optional, Tuple, Union
9
10
 
10
11
  import tenacity
@@ -12,15 +13,15 @@ import tenacity
12
13
  from mpflash.basicgit import get_git_describe
13
14
  from stubber.publish.helpers import get_module_docstring
14
15
 
15
- try:
16
- import tomllib # type: ignore
17
- except ModuleNotFoundError:
18
- import tomli as tomllib # type: ignore
16
+ if sys.version_info >= (3, 11):
17
+ import tomllib # type: ignore
18
+ else:
19
+ import tomli as tomllib # type: ignore
19
20
 
20
21
  from typing import NewType
21
22
 
22
23
  import tomli_w
23
- from loguru import logger as log
24
+ from mpflash.logger import log
24
25
  from packaging.version import Version, parse
25
26
  from pysondb import PysonDB
26
27
 
@@ -125,9 +126,15 @@ class VersionedPackage(object):
125
126
  parts = describe.split("-", 3)
126
127
  ver = parts[0]
127
128
  if len(parts) > 1:
128
- rc = parts[1] if parts[1].isdigit() else parts[2] if len(parts) > 2 and parts[2].isdigit() else 1
129
+ rc = (
130
+ parts[1]
131
+ if parts[1].isdigit()
132
+ else parts[2] if len(parts) > 2 and parts[2].isdigit() else 1
133
+ )
129
134
  rc = int(rc)
130
- base = bump_version(Version(ver), minor_bump=True) if parts[1] != V_PREVIEW else Version(ver)
135
+ base = (
136
+ bump_version(Version(ver), minor_bump=True) if parts[1] != V_PREVIEW else Version(ver)
137
+ )
131
138
  return str(bump_version(base, rc=rc))
132
139
  # raise ValueError("cannot determine next version number micropython")
133
140
 
@@ -304,7 +311,9 @@ class Builder(VersionedPackage):
304
311
  # Check if all stub source folders exist
305
312
  for stub_type, src_path in self.stub_sources:
306
313
  if not (CONFIG.stub_path / src_path).exists():
307
- raise FileNotFoundError(f"Could not find stub source folder {CONFIG.stub_path / src_path}")
314
+ raise FileNotFoundError(
315
+ f"Could not find stub source folder {CONFIG.stub_path / src_path}"
316
+ )
308
317
 
309
318
  # 1 - Copy the stubs to the package, directly in the package folder (no folders)
310
319
  # for stub_type, fw_path in [s for s in self.stub_sources]:
@@ -315,7 +324,9 @@ class Builder(VersionedPackage):
315
324
  self.copy_folder(stub_type, src_path)
316
325
  except OSError as e:
317
326
  if stub_type != StubSource.FROZEN:
318
- raise FileNotFoundError(f"Could not find stub source folder {src_path}") from e
327
+ raise FileNotFoundError(
328
+ f"Could not find stub source folder {src_path}"
329
+ ) from e
319
330
  else:
320
331
  log.debug(f"Error copying stubs from : {CONFIG.stub_path / src_path}, {e}")
321
332
  finally:
@@ -707,7 +718,8 @@ class PoetryBuilder(Builder):
707
718
  _pyproject = self.pyproject
708
719
  assert _pyproject is not None, "No pyproject.toml file found"
709
720
  _pyproject["tool"]["poetry"]["packages"] = [
710
- {"include": p.relative_to(self.package_path).as_posix()} for p in sorted((self.package_path).rglob("*.pyi"))
721
+ {"include": p.relative_to(self.package_path).as_posix()}
722
+ for p in sorted((self.package_path).rglob("*.pyi"))
711
723
  ]
712
724
  # write out the pyproject.toml file
713
725
  self.pyproject = _pyproject
@@ -851,7 +863,9 @@ class StubPackage(PoetryBuilder):
851
863
  # check if the sources exist
852
864
  ok = self.are_package_sources_available()
853
865
  if not ok:
854
- log.debug(f"{self.package_name}: skipping as one or more source stub folders are missing")
866
+ log.debug(
867
+ f"{self.package_name}: skipping as one or more source stub folders are missing"
868
+ )
855
869
  self.status["error"] = "Skipped, stub folder(s) missing"
856
870
  shutil.rmtree(self.package_path.as_posix())
857
871
  self._publish = False # type: ignore
@@ -873,7 +887,9 @@ class StubPackage(PoetryBuilder):
873
887
  self,
874
888
  production: bool, # PyPI or Test-PyPi - USED TO FIND THE NEXT VERSION NUMBER
875
889
  force=False, # BUILD even if no changes
876
- ) -> bool: # sourcery skip: default-mutable-arg, extract-duplicate-method, require-parameter-annotation
890
+ ) -> (
891
+ bool
892
+ ): # sourcery skip: default-mutable-arg, extract-duplicate-method, require-parameter-annotation
877
893
  """
878
894
  Build a package
879
895
  look up the previous package version in the dabase
@@ -899,14 +915,18 @@ class StubPackage(PoetryBuilder):
899
915
  if force:
900
916
  log.info(f"Force build: {self.package_name} {self.pkg_version} ")
901
917
  else:
902
- log.info(f"Found changes to package sources: {self.package_name} {self.pkg_version} ")
918
+ log.info(
919
+ f"Found changes to package sources: {self.package_name} {self.pkg_version} "
920
+ )
903
921
  log.trace(f"Old hash {self.hash} != New hash {self.calculate_hash()}")
904
922
  # Build the distribution files
905
923
  old_ver = self.pkg_version
906
924
  self.pkg_version = self.next_package_version(production)
907
925
  self.status["version"] = self.pkg_version
908
926
  # to get the next version
909
- log.debug(f"{self.package_name}: bump version for {old_ver} to {self.pkg_version } {'production' if production else 'test'}")
927
+ log.debug(
928
+ f"{self.package_name}: bump version for {old_ver} to {self.pkg_version } {'production' if production else 'test'}"
929
+ )
910
930
  self.write_package_json()
911
931
  log.trace(f"New hash: {self.package_name} {self.pkg_version} {self.hash}")
912
932
  if self.poetry_build():
@@ -959,7 +979,9 @@ class StubPackage(PoetryBuilder):
959
979
  # Publish the package to PyPi, Test-PyPi or Github
960
980
  if self.is_changed():
961
981
  if self.mpy_version in SET_PREVIEW and production and not force:
962
- log.warning("version: `latest` package will only be available on Github, and not published to PyPi.")
982
+ log.warning(
983
+ "version: `latest` package will only be available on Github, and not published to PyPi."
984
+ )
963
985
  self.status["result"] = "Published to GitHub"
964
986
  else:
965
987
  return self.publish_distribution(dry_run, production, db)
@@ -988,7 +1010,9 @@ class StubPackage(PoetryBuilder):
988
1010
  if not dry_run:
989
1011
  pub_ok = self.poetry_publish(production=production)
990
1012
  else:
991
- log.warning(f"{self.package_name}: Dry run, not publishing to {'' if production else 'Test-'}PyPi")
1013
+ log.warning(
1014
+ f"{self.package_name}: Dry run, not publishing to {'' if production else 'Test-'}PyPi"
1015
+ )
992
1016
  pub_ok = True
993
1017
  if not pub_ok:
994
1018
  log.warning(f"{self.package_name}: Publish failed for {self.pkg_version}")
stubber/rst/classsort.py CHANGED
@@ -4,10 +4,11 @@ note that this does not take multiple inheritance into account
4
4
  ref : https://stackoverflow.com/questions/34964878/python-generate-a-dictionarytree-from-a-list-of-tuples/35049729#35049729
5
5
  with modification
6
6
  """
7
+
7
8
  import re
8
9
  from typing import List
9
10
 
10
- from loguru import logger as log
11
+ from mpflash.logger import log
11
12
 
12
13
  __all__ = ["sort_classes"]
13
14
  RE_CLASS = re.compile(r"class\s+(?P<class>\w+)(\((?P<parent>\w*)\))?")
stubber/rst/lookup.py CHANGED
@@ -247,6 +247,7 @@ MODULE_GLUE = {
247
247
  #
248
248
  # "builtins": ["from stdlib.builtins import *"], # integrate STDLIB
249
249
  # "machine": ["from network import AbstractNIC"], # NIC is an abstract class, although not defined or used as such
250
+ "espnow": ["from _espnow import ESPNowBase"], # ESPNowBase is an undocumented base class
250
251
  }
251
252
 
252
253
 
stubber/rst/reader.py CHANGED
@@ -67,8 +67,7 @@ import re
67
67
  from pathlib import Path
68
68
  from typing import List, Optional, Tuple
69
69
 
70
- from loguru import logger as log
71
-
70
+ from mpflash.logger import log
72
71
  from mpflash.versions import V_PREVIEW
73
72
  from stubber.rst import (
74
73
  CHILD_PARENT_CLASS,
@@ -679,15 +678,16 @@ class RSTParser(RSTReader):
679
678
 
680
679
  parent_class += method
681
680
 
682
- def lstrip_self(self, params):
681
+ def lstrip_self(self, params: str):
683
682
  """
684
683
  To avoid duplicate selfs,
685
684
  Remove `self,` from the start of the parameters
686
685
  """
687
- if params.startswith("self,"):
688
- params = params[6:]
689
- elif params.startswith("self ,"):
690
- params = params[7:]
686
+ params = params.lstrip()
687
+
688
+ for start in ["self,", "self ,", "self ", "self"]:
689
+ if params.startswith(start):
690
+ params = params[len(start) :]
691
691
  return params
692
692
 
693
693
  def parse_exception(self):
@@ -15,7 +15,7 @@ from pathlib import Path
15
15
  from typing import List, Tuple
16
16
 
17
17
  import stubber.utils as utils
18
- from loguru import logger as log
18
+ from mpflash.logger import log
19
19
 
20
20
 
21
21
  def process(folder: Path, pattern: str):
@@ -34,7 +34,9 @@ def process(folder: Path, pattern: str):
34
34
  signature = str(item[3]).split("::")[-1].strip()
35
35
  docstring = item[4]
36
36
 
37
- r = utils._type_from_context(docstring=docstring, signature=signature, module=module_name)
37
+ r = utils._type_from_context(
38
+ docstring=docstring, signature=signature, module=module_name
39
+ )
38
40
  report.append(
39
41
  {
40
42
  "signature": signature,
@@ -49,11 +51,17 @@ def process(folder: Path, pattern: str):
49
51
  }
50
52
  )
51
53
  # isGood = r["confidence"] >= 0.5 and r["confidence"] <= 0.8 and item[2] != ""
52
- isBad = float(r["confidence"]) <= 0.5 and float(r["confidence"]) <= 0.8 and item[2] != ""
54
+ isBad = (
55
+ float(r["confidence"]) <= 0.5
56
+ and float(r["confidence"]) <= 0.8
57
+ and item[2] != ""
58
+ )
53
59
  if isBad:
54
60
  context = item[3] + ".".join((item[0], item[1], item[2]))
55
61
  try:
56
- log.debug(f"{context:40} {r['type']:<15} - {r['confidence']} {r['match'].groups('return')}")
62
+ log.debug(
63
+ f"{context:40} {r['type']:<15} - {r['confidence']} {r['match'].groups('return')}"
64
+ )
57
65
  except Exception:
58
66
  log.debug(f"{context:40} {r['type']:<15} - {r['confidence']} ")
59
67
 
stubber/rst/rst_utils.py CHANGED
@@ -32,13 +32,14 @@ to do:
32
32
  https://docs.microsoft.com/en-us/azure/machine-learning/quickstart-create-resources
33
33
  -
34
34
  """
35
+
35
36
  # ref: https://regex101.com/codegen?language=python
36
37
  # https://regex101.com/r/Ni8g2z/2
37
38
 
38
39
  import re
39
40
  from typing import Dict, List, Optional, Union
40
41
 
41
- from loguru import logger as log
42
+ from mpflash.logger import log
42
43
 
43
44
  from .lookup import LOOKUP_LIST, NONE_VERBS, TYPING_IMPORT
44
45
 
@@ -7,7 +7,7 @@ import os
7
7
  from pathlib import Path
8
8
  from typing import List, Optional
9
9
 
10
- from loguru import logger as log
10
+ from mpflash.logger import log
11
11
 
12
12
  from stubber import utils
13
13
  from stubber.rst import DOCSTUB_SKIP, U_MODULES
@@ -400,7 +400,7 @@ class ManifestFile:
400
400
  self._metadata.pop()
401
401
 
402
402
  def _require_from_path(self, library_path, name, version, extra_kwargs):
403
- for root, dirnames, filenames in os.walk(library_path):
403
+ for root, dirnames, filenames in os.walk(library_path): # type: ignore
404
404
  if os.path.basename(root) == name and "manifest.py" in filenames:
405
405
  self.include(root, is_require=True, **extra_kwargs)
406
406
  return True
@@ -7,7 +7,7 @@
7
7
  # from pathlib import Path
8
8
  # from typing import List, Optional, Tuple
9
9
 
10
- # from loguru import logger as log
10
+ # from mpflash.logger import log
11
11
 
12
12
  # from mpflash.versions import V_PREVIEW
13
13
 
@@ -15,7 +15,7 @@ for this :
15
15
  from pathlib import Path
16
16
  from typing import List, Optional, Set
17
17
 
18
- from loguru import logger as log
18
+ from mpflash.logger import log
19
19
 
20
20
 
21
21
  def read_modules(path: Optional[Path] = None) -> Set[str]:
stubber/utils/config.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from pathlib import Path
4
4
  from typing import List
5
5
 
6
- from loguru import logger as log
6
+ from mpflash.logger import log
7
7
  from typedconfig.config import Config, key, section
8
8
  from typedconfig.source import EnvironmentConfigSource
9
9
 
@@ -17,7 +17,9 @@ from .typed_config_toml import TomlConfigSource
17
17
  class StubberConfig(Config):
18
18
  "stubber configuration class"
19
19
  # relative to stubs folder
20
- fallback_path: Path = key(key_name="fallback-path", cast=Path, required=False, default=Path("typings/fallback"))
20
+ fallback_path: Path = key(
21
+ key_name="fallback-path", cast=Path, required=False, default=Path("typings/fallback")
22
+ )
21
23
  "a Path to the fallback stubs directory"
22
24
 
23
25
  # ------------------------------------------------------------------------------------------
@@ -25,16 +27,24 @@ class StubberConfig(Config):
25
27
  repo_path: Path = key(key_name="repo-path", cast=Path, required=False, default=Path("./repos"))
26
28
  "a Path to the repo directory"
27
29
 
28
- mpy_path: Path = key(key_name="mpy-path", cast=Path, required=False, default=Path("micropython"))
30
+ mpy_path: Path = key(
31
+ key_name="mpy-path", cast=Path, required=False, default=Path("micropython")
32
+ )
29
33
  "a Path to the micropython folder in the repos directory"
30
34
 
31
- mpy_lib_path: Path = key(key_name="mpy-lib-path", cast=Path, required=False, default=Path("micropython-lib"))
35
+ mpy_lib_path: Path = key(
36
+ key_name="mpy-lib-path", cast=Path, required=False, default=Path("micropython-lib")
37
+ )
32
38
  "a Path to the micropython-lib folder in the repos directory"
33
39
 
34
- mpy_stubs_path: Path = key(key_name="mpy-stubs-path", cast=Path, required=False, default=Path("micropython-stubs"))
40
+ mpy_stubs_path: Path = key(
41
+ key_name="mpy-stubs-path", cast=Path, required=False, default=Path("micropython-stubs")
42
+ )
35
43
  "a Path to the micropython-stubs folder in the repos directory (or current directory)"
36
44
 
37
- stable_version: str = key(key_name="stable-version", cast=str, required=False, default="1.20.0")
45
+ stable_version: str = key(
46
+ key_name="stable-version", cast=str, required=False, default="1.20.0"
47
+ )
38
48
 
39
49
  "last published stable"
40
50
 
@@ -113,7 +123,9 @@ def readconfig(filename: str = "pyproject.toml", prefix: str = "tool.", must_exi
113
123
  # add provider sources to the config
114
124
  config.add_source(EnvironmentConfigSource())
115
125
  if use_toml:
116
- config.add_source(TomlConfigSource(filename, prefix=prefix, must_exist=must_exist)) # ,"tools.micropython-stubber"))
126
+ config.add_source(
127
+ TomlConfigSource(filename, prefix=prefix, must_exist=must_exist)
128
+ ) # ,"tools.micropython-stubber"))
117
129
  config.read()
118
130
  return config
119
131