micropython-stubber 1.23.3__py3-none-any.whl → 1.24.1__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 (69) hide show
  1. {micropython_stubber-1.23.3.dist-info → micropython_stubber-1.24.1.dist-info}/METADATA +29 -11
  2. {micropython_stubber-1.23.3.dist-info → micropython_stubber-1.24.1.dist-info}/RECORD +68 -65
  3. {micropython_stubber-1.23.3.dist-info → micropython_stubber-1.24.1.dist-info}/WHEEL +1 -1
  4. mpflash/README.md +2 -2
  5. mpflash/mpflash/basicgit.py +22 -2
  6. mpflash/mpflash/common.py +23 -13
  7. mpflash/mpflash/downloaded.py +10 -2
  8. mpflash/mpflash/flash/esp.py +1 -1
  9. mpflash/mpflash/mpboard_id/__init__.py +9 -4
  10. mpflash/mpflash/mpboard_id/add_boards.py +25 -14
  11. mpflash/mpflash/mpboard_id/board.py +2 -2
  12. mpflash/mpflash/mpboard_id/board_id.py +10 -6
  13. mpflash/mpflash/mpboard_id/board_info.zip +0 -0
  14. mpflash/mpflash/mpremoteboard/__init__.py +13 -8
  15. mpflash/mpflash/vendor/board_database.py +185 -0
  16. mpflash/mpflash/vendor/readme.md +10 -1
  17. mpflash/mpflash/versions.py +28 -40
  18. mpflash/poetry.lock +1147 -231
  19. mpflash/pyproject.toml +4 -3
  20. stubber/__init__.py +1 -1
  21. stubber/board/createstubs.py +76 -34
  22. stubber/board/createstubs_db.py +34 -25
  23. stubber/board/createstubs_db_min.py +90 -83
  24. stubber/board/createstubs_db_mpy.mpy +0 -0
  25. stubber/board/createstubs_mem.py +34 -25
  26. stubber/board/createstubs_mem_min.py +123 -116
  27. stubber/board/createstubs_mem_mpy.mpy +0 -0
  28. stubber/board/createstubs_min.py +154 -145
  29. stubber/board/createstubs_mpy.mpy +0 -0
  30. stubber/board/modulelist.txt +16 -0
  31. stubber/codemod/enrich.py +301 -86
  32. stubber/codemod/merge_docstub.py +251 -66
  33. stubber/codemod/test_enrich.py +87 -0
  34. stubber/codemod/visitors/type_helpers.py +182 -0
  35. stubber/commands/build_cmd.py +16 -3
  36. stubber/commands/clone_cmd.py +3 -3
  37. stubber/commands/config_cmd.py +4 -2
  38. stubber/commands/enrich_folder_cmd.py +33 -21
  39. stubber/commands/get_core_cmd.py +1 -2
  40. stubber/commands/get_docstubs_cmd.py +60 -6
  41. stubber/commands/get_frozen_cmd.py +15 -12
  42. stubber/commands/get_mcu_cmd.py +3 -3
  43. stubber/commands/merge_cmd.py +1 -2
  44. stubber/commands/publish_cmd.py +19 -4
  45. stubber/commands/stub_cmd.py +3 -3
  46. stubber/commands/switch_cmd.py +3 -5
  47. stubber/commands/variants_cmd.py +3 -3
  48. stubber/cst_transformer.py +52 -17
  49. stubber/freeze/common.py +27 -11
  50. stubber/freeze/freeze_manifest_2.py +8 -1
  51. stubber/freeze/get_frozen.py +4 -1
  52. stubber/merge_config.py +111 -0
  53. stubber/minify.py +1 -2
  54. stubber/publish/database.py +51 -10
  55. stubber/publish/merge_docstubs.py +38 -17
  56. stubber/publish/package.py +32 -18
  57. stubber/publish/publish.py +8 -8
  58. stubber/publish/stubpackage.py +117 -50
  59. stubber/rst/lookup.py +205 -41
  60. stubber/rst/reader.py +106 -59
  61. stubber/rst/rst_utils.py +24 -11
  62. stubber/stubber.py +1 -1
  63. stubber/stubs_from_docs.py +31 -13
  64. stubber/update_module_list.py +2 -2
  65. stubber/utils/config.py +33 -13
  66. stubber/utils/post.py +9 -6
  67. stubber/publish/missing_class_methods.py +0 -51
  68. {micropython_stubber-1.23.3.dist-info → micropython_stubber-1.24.1.dist-info}/LICENSE +0 -0
  69. {micropython_stubber-1.23.3.dist-info → micropython_stubber-1.24.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,182 @@
1
+ """
2
+ Gather all TypeVar and TypeAlias assignments in a module.
3
+ """
4
+
5
+ from typing import List, Sequence, Tuple, Union
6
+
7
+ import libcst
8
+ import libcst.matchers as m
9
+ from libcst import SimpleStatementLine
10
+ from libcst.codemod._context import CodemodContext
11
+ from libcst.codemod._visitor import ContextAwareTransformer, ContextAwareVisitor
12
+ from libcst.codemod.visitors._add_imports import _skip_first
13
+ from typing_extensions import TypeAlias
14
+
15
+ from mpflash.logger import log
16
+
17
+ TypeHelper: TypeAlias = Union[libcst.Assign, libcst.AnnAssign]
18
+ TypeHelpers: TypeAlias = List[TypeHelper]
19
+ Statement: TypeAlias = Union[libcst.SimpleStatementLine, libcst.BaseCompoundStatement]
20
+
21
+ _mod = libcst.parse_module("") # Debugging aid : _mod.code_for_node(node)
22
+ _code = _mod.code_for_node # Debugging aid : _code(node)
23
+
24
+
25
+ def is_TypeAlias(statement) -> bool:
26
+ "Annotated Assign - Foo:TypeAlias = ..."
27
+ if m.matches(statement, m.SimpleStatementLine()):
28
+ statement = statement.body[0]
29
+ return m.matches(
30
+ statement,
31
+ m.AnnAssign(annotation=m.Annotation(annotation=m.Name(value="TypeAlias"))),
32
+ )
33
+
34
+
35
+ def is_TypeVar(statement):
36
+ "Assing - Foo = Typevar(...)"
37
+ if m.matches(statement, m.SimpleStatementLine()):
38
+ statement = statement.body[0]
39
+ return m.matches(
40
+ statement,
41
+ m.Assign(value=m.Call(func=m.Name(value="TypeVar"))),
42
+ )
43
+
44
+
45
+ def is_ParamSpec(statement):
46
+ "Assign - Foo = ParamSpec(...)"
47
+ if m.matches(statement, m.SimpleStatementLine()):
48
+ statement = statement.body[0]
49
+ return m.matches(
50
+ statement,
51
+ m.Assign(value=m.Call(func=m.Name(value="ParamSpec"))),
52
+ )
53
+
54
+
55
+ def is_import(statement):
56
+ "import - import foo"
57
+ return m.matches(statement, m.SimpleStatementLine(body=[m.ImportFrom() | m.Import()]))
58
+
59
+
60
+ class GatherTypeHelpers(ContextAwareVisitor):
61
+ """
62
+ A class for tracking visited TypeVars and TypeAliases.
63
+ """
64
+
65
+ def __init__(self, context: CodemodContext) -> None:
66
+ super().__init__(context)
67
+ # Track all of the TypeVar, TypeAlias and Paramspec assignments found
68
+ self.all_typehelpers: TypeHelpers = []
69
+
70
+ def visit_Assign(self, node: libcst.Assign) -> None:
71
+ """
72
+ Find all TypeVar assignments in the module.
73
+ format: T = TypeVar("T", int, float, str, bytes, Tuple)
74
+ """
75
+ # is this a TypeVar assignment?
76
+ # needs to be more robust
77
+ if is_TypeVar(node) or is_ParamSpec(node):
78
+ self.all_typehelpers.append(node)
79
+
80
+ def visit_AnnAssign(self, node: libcst.AnnAssign) -> None:
81
+ """ "
82
+ Find all TypeAlias assignments in the module.
83
+ format: T: TypeAlias = str
84
+ """
85
+ if is_TypeAlias(node):
86
+ self.all_typehelpers.append(node)
87
+
88
+
89
+ class AddTypeHelpers(ContextAwareTransformer):
90
+ """
91
+ Visitor loosly based on AddImportsVisitor
92
+ """
93
+
94
+ CONTEXT_KEY = "AddTypeHelpers"
95
+
96
+ def __init__(self, context: CodemodContext) -> None:
97
+ super().__init__(context)
98
+ self.new_typehelpers: TypeHelpers = context.scratch.get(self.CONTEXT_KEY, [])
99
+ self.all_typehelpers: TypeHelpers = []
100
+
101
+ @classmethod
102
+ def add_typevar(cls, context: CodemodContext, node: libcst.Assign):
103
+ new_typehelpers = context.scratch.get(cls.CONTEXT_KEY, [])
104
+ new_typehelpers.append(node)
105
+ context.scratch[cls.CONTEXT_KEY] = new_typehelpers
106
+ # add the typevar to the module
107
+
108
+ def leave_Module(
109
+ self,
110
+ original_node: libcst.Module,
111
+ updated_node: libcst.Module,
112
+ ) -> libcst.Module:
113
+ if not self.new_typehelpers:
114
+ return updated_node
115
+
116
+ # split the module into 3 parts
117
+ # before and after the insertions point , and a list of the TV and TA statements
118
+ (
119
+ statements_before,
120
+ helper_statements,
121
+ statements_after,
122
+ ) = self._split_module(original_node, updated_node)
123
+
124
+ # simpler to compare as text than to compare the nodes -
125
+ existing_targets = [
126
+ helper.body[0].targets[0].target.value # type: ignore
127
+ for helper in helper_statements
128
+ if is_TypeVar(helper) or is_ParamSpec(helper)
129
+ ] + [
130
+ helper.body[0].target.value # type: ignore
131
+ for helper in helper_statements
132
+ if is_TypeAlias(helper)
133
+ ]
134
+ statements_to_add = []
135
+ for new_typehelper in self.new_typehelpers:
136
+ if isinstance(new_typehelper, libcst.AnnAssign):
137
+ if new_typehelper.target.value not in existing_targets: # type: ignore
138
+ statements_to_add.append(SimpleStatementLine(body=[new_typehelper]))
139
+ elif isinstance(new_typehelper, libcst.Assign):
140
+ if new_typehelper.targets[0].target.value not in existing_targets: # type: ignore
141
+ statements_to_add.append(SimpleStatementLine(body=[new_typehelper]))
142
+
143
+ body = (
144
+ *statements_before,
145
+ *statements_to_add,
146
+ *statements_after,
147
+ )
148
+
149
+ return updated_node.with_changes(body=body)
150
+
151
+ def _split_module(
152
+ self,
153
+ orig_module: libcst.Module,
154
+ updated_module: libcst.Module,
155
+ ) -> Tuple[Sequence[Statement], Sequence[libcst.SimpleStatementLine], Sequence[Statement]]:
156
+ """
157
+ Split the module into 3 parts:
158
+ - before any TypeAlias, TypeVar or ParamSpec statements
159
+ - the TypeAlias and TypeVar statements
160
+ - the rest of the module after the TypeAlias and TypeVar statements
161
+ """
162
+ last_import = first_typehelper = last_typehelper = -1
163
+ start = 0
164
+ if _skip_first(orig_module):
165
+ start = 1
166
+
167
+ for i, statement in enumerate(orig_module.body[start:]):
168
+ if is_import(statement):
169
+ last_import = i + start
170
+ continue
171
+ if is_TypeVar(statement) or is_TypeAlias(statement) or is_ParamSpec(statement):
172
+ if first_typehelper == -1:
173
+ first_typehelper = i + start
174
+ last_typehelper = i + start
175
+ # insert as high as possible, but after the last import and last TypeVar/TypeAlias statement
176
+ insert_after = max(start, last_import + 1, last_typehelper + 1)
177
+ assert insert_after != -1, "insert_after must be != -1"
178
+ #
179
+ before = list(updated_module.body[:insert_after])
180
+ after = list(updated_module.body[insert_after:])
181
+ helper_statements: Sequence[libcst.SimpleStatementLine] = list(updated_module.body[first_typehelper : last_typehelper + 1]) # type: ignore
182
+ return (before, helper_statements, after)
@@ -4,7 +4,8 @@ from typing import List, Union
4
4
 
5
5
  import rich_click as click
6
6
  from mpflash.logger import log
7
- from tabulate import tabulate
7
+ from rich.console import Console
8
+ from rich.table import Table
8
9
 
9
10
  from stubber.commands.cli import stubber_cli
10
11
  from stubber.publish.defaults import GENERIC_U
@@ -77,7 +78,6 @@ def cli_build(
77
78
  "Multiple versions are not supported yet\n See https://github.com/Josverl/micropython-stubber/issues/487"
78
79
  )
79
80
 
80
- # db = get_database(publish_path=CONFIG.publish_path, production=production)
81
81
  log.info(f"Build {family} {versions} {ports} {boards}")
82
82
 
83
83
  results = build_multiple(
@@ -91,4 +91,17 @@ def cli_build(
91
91
  )
92
92
  # log the number of results with no error
93
93
  log.info(f"Built {len([r for r in results if not r['error']])} stub packages")
94
- print(tabulate(results, headers="keys"))
94
+ console = Console()
95
+ if not results:
96
+ console.print("No results to publish")
97
+ return
98
+ table = Table(title="Build Results", show_header=True, header_style="bold magenta")
99
+
100
+ for key in results[0].keys():
101
+ table.add_column(key)
102
+
103
+ for result in results:
104
+ if result["result"] != "-":
105
+ table.add_row(*[str(result[key]) for key in result.keys()])
106
+
107
+ console.print(table)
@@ -7,12 +7,12 @@ import os
7
7
  from pathlib import Path
8
8
  from typing import List, Tuple, Union
9
9
 
10
- import rich_click as click
11
10
  import mpflash.basicgit as git
11
+ import rich_click as click
12
12
  from mpflash.logger import log
13
- from stubber.utils.config import CONFIG
14
13
 
15
- from .cli import stubber_cli
14
+ from stubber.commands.cli import stubber_cli
15
+ from stubber.utils.config import CONFIG
16
16
 
17
17
  ##########################################################################################
18
18
  # log = logging.getLogger("stubber")
@@ -4,10 +4,9 @@
4
4
 
5
5
  from mpflash.logger import log
6
6
 
7
+ from stubber.commands.cli import stubber_cli
7
8
  from stubber.utils.config import CONFIG
8
9
 
9
- from .cli import stubber_cli
10
-
11
10
 
12
11
  @stubber_cli.command(name="show-config")
13
12
  def cli_config():
@@ -27,3 +26,6 @@ def cli_config():
27
26
  log.info(f"CONFIG.stub_path {CONFIG.stub_path}")
28
27
  log.info(f"CONFIG.publish_path {CONFIG.publish_path}")
29
28
  log.info(f"CONFIG.template_path {CONFIG.template_path}")
29
+ log.info(f"CONFIG.all_versions {CONFIG.all_versions}")
30
+ log.info(f"CONFIG.stable_version {CONFIG.stable_version}")
31
+ log.info(f"CONFIG.preview_version {CONFIG.preview_version}")
@@ -1,5 +1,5 @@
1
1
  """
2
- enrich machinestubs with docstubs
2
+ Enrich mcu/firmware stubs with information from the docstubs
3
3
  """
4
4
 
5
5
  from pathlib import Path
@@ -9,28 +9,30 @@ import rich_click as click
9
9
  from mpflash.logger import log
10
10
 
11
11
  from stubber.codemod.enrich import enrich_folder
12
+ from stubber.commands.cli import stubber_cli
12
13
  from stubber.utils.config import CONFIG
13
14
 
14
- from .cli import stubber_cli
15
-
16
15
 
17
16
  @stubber_cli.command(name="enrich")
18
17
  @click.option(
18
+ "--dest",
19
+ "--destination",
20
+ "-d",
19
21
  "--stubs",
20
- "-s",
21
- "stubs_folder",
22
+ "dest_folder",
22
23
  default=CONFIG.stub_path.as_posix(),
23
24
  type=click.Path(exists=True, file_okay=True, dir_okay=True),
24
- help="File or folder containing the MCU stubs to be updated",
25
+ help="The destination file or folder containing the stubs stubs to be updated",
25
26
  show_default=True,
26
27
  )
27
28
  @click.option(
29
+ "--source",
30
+ "-s",
28
31
  "--docstubs",
29
- "-ds",
30
- "docstubs_folder",
32
+ "source_folder",
31
33
  default=CONFIG.stub_path.as_posix(),
32
34
  type=click.Path(exists=True, file_okay=True, dir_okay=True),
33
- help="File or folder containing the docstubs to be applied",
35
+ help="The source file or folder containing the docstubs to be read",
34
36
  show_default=True,
35
37
  )
36
38
  @click.option("--diff", default=False, help="Show diff", show_default=True, is_flag=True)
@@ -42,30 +44,40 @@ from .cli import stubber_cli
42
44
  is_flag=True,
43
45
  )
44
46
  @click.option(
45
- "--package-name",
46
- "-p",
47
- "package_name",
48
- default="",
49
- help="Package name to be enriched (Optional)",
47
+ "--params-only",
48
+ "params_only",
49
+ default=False,
50
+ help="Copy only the parameters, not the docstrings (unless the docstring is missing)",
50
51
  show_default=True,
52
+ is_flag=True,
51
53
  )
54
+ # @click.option(
55
+ # "--package-name",
56
+ # "-p",
57
+ # "package_name",
58
+ # default="",
59
+ # help="Package name to be enriched (Optional)",
60
+ # show_default=True,
61
+ # )
52
62
  def cli_enrich_folder(
53
- stubs_folder: Union[str, Path],
54
- docstubs_folder: Union[str, Path],
63
+ dest_folder: Union[str, Path],
64
+ source_folder: Union[str, Path],
55
65
  diff: bool = False,
56
66
  dry_run: bool = False,
57
- package_name: str = "",
67
+ params_only: bool = True,
68
+ # package_name: str = "",
58
69
  ):
59
70
  """
60
71
  Enrich the stubs in stub_folder with the docstubs in docstubs_folder.
61
72
  """
62
73
  write_back = not dry_run
63
- log.info(f"Enriching {stubs_folder} with {docstubs_folder}")
74
+ log.info(f"Enriching {dest_folder} with {source_folder}")
64
75
  _ = enrich_folder(
65
- Path(stubs_folder),
66
- Path(docstubs_folder),
76
+ Path(source_folder),
77
+ Path(dest_folder),
67
78
  show_diff=diff,
68
79
  write_back=write_back,
69
80
  require_docstub=False,
70
- package_name=package_name,
81
+ # package_name=package_name,
82
+ params_only=params_only,
71
83
  )
@@ -12,10 +12,9 @@ from mpflash.logger import log
12
12
 
13
13
  import stubber.get_cpython as get_cpython
14
14
  import stubber.utils as utils
15
+ from stubber.commands.cli import stubber_cli
15
16
  from stubber.utils.config import CONFIG
16
17
 
17
- from .cli import stubber_cli
18
-
19
18
  ##########################################################################################
20
19
  # log = logging.getLogger("stubber")
21
20
  #########################################################################################
@@ -5,18 +5,19 @@ get-docstubs
5
5
 
6
6
  from pathlib import Path
7
7
  from typing import Optional
8
+ from packaging.version import Version
8
9
 
10
+ import mpflash.basicgit as git
9
11
  import rich_click as click
10
12
  from mpflash.logger import log
11
13
 
12
- import mpflash.basicgit as git
14
+ from stubber.codemod.enrich import enrich_folder
13
15
  import stubber.utils as utils
16
+ from stubber.commands.cli import stubber_cli
14
17
  from stubber.stubs_from_docs import generate_from_rst
15
18
  from stubber.utils.config import CONFIG
16
19
  from stubber.utils.repos import fetch_repos
17
20
 
18
- from .cli import stubber_cli
19
-
20
21
  ##########################################################################################
21
22
  # log = logging.getLogger("stubber")
22
23
  #########################################################################################
@@ -47,14 +48,37 @@ from .cli import stubber_cli
47
48
  "--version", "--tag", default="", type=str, help="Version number to use. [default: Git tag]"
48
49
  )
49
50
  @click.option("--black/--no-black", "-b/-nb", default=True, help="Run black", show_default=True)
51
+ @click.option(
52
+ "--autoflake/--no-autoflake",
53
+ default=True,
54
+ help="Run autoflake to clean imports",
55
+ show_default=True,
56
+ )
57
+ @click.option(
58
+ "--clean-rst/--no-clean-rst",
59
+ "-b/-nb",
60
+ default=True,
61
+ help="remove .rST constructs from the docstrings",
62
+ show_default=True,
63
+ )
64
+ @click.option(
65
+ "--enrich",
66
+ is_flag=True,
67
+ default=False,
68
+ help="Enrich with type information from micropython-reference",
69
+ show_default=True,
70
+ )
50
71
  @click.pass_context
51
72
  def cli_docstubs(
52
73
  ctx: click.Context,
53
74
  path: Optional[str] = None,
54
75
  target: Optional[str] = None,
55
76
  black: bool = True,
77
+ autoflake: bool = True,
78
+ clean_rst: bool = True,
56
79
  basename: Optional[str] = None,
57
80
  version: str = "",
81
+ enrich: bool = False,
58
82
  ):
59
83
  """
60
84
  Build stubs from documentation.
@@ -80,13 +104,43 @@ def cli_docstubs(
80
104
  result = fetch_repos(version, CONFIG.mpy_path, CONFIG.mpy_lib_path)
81
105
  if not result:
82
106
  return -1
83
- # get the current checked out version
84
- version = utils.checkedout_version(CONFIG.mpy_path)
107
+ else:
108
+ # get the current checked out version
109
+ version = utils.checkedout_version(CONFIG.mpy_path)
85
110
 
86
111
  release = git.get_local_tag(rst_path.as_posix(), abbreviate=False) or ""
87
112
 
88
113
  dst_path = Path(target) / f"{basename}-{utils.clean_version(version, flat=True)}-docstubs"
89
114
 
90
115
  log.info(f"Get docstubs for MicroPython {utils.clean_version(version, drop_v=False)}")
91
- generate_from_rst(rst_path, dst_path, version, release=release, suffix=".pyi", black=black)
116
+ generate_from_rst(
117
+ rst_path,
118
+ dst_path,
119
+ version,
120
+ release=release,
121
+ suffix=".pyi",
122
+ black=black,
123
+ autoflake=autoflake,
124
+ clean_rst=clean_rst,
125
+ )
126
+
127
+ if enrich:
128
+ if Version(version) < Version("1.24"):
129
+ log.warning(f"Enriching is not supported for version {version}")
130
+ else:
131
+ # !stubber enrich --params-only --source {reference} --dest {docstubs}
132
+ reference_path = CONFIG.stub_path.parent / "micropython-reference"
133
+ log.info(f"Enriching from {reference_path}")
134
+ _ = enrich_folder(
135
+ reference_path,
136
+ dst_path,
137
+ show_diff=False,
138
+ write_back=True,
139
+ require_docstub=False,
140
+ params_only=True,
141
+ )
142
+ log.info("::group:: start post processing of retrieved stubs")
143
+ # do not run stubgen
144
+ utils.do_post_processing([dst_path], stubgen=False, black=black, autoflake=autoflake)
145
+
92
146
  log.info("::group:: Done")
@@ -7,16 +7,15 @@ from pathlib import Path
7
7
  from typing import List, Optional
8
8
 
9
9
  import rich_click as click
10
- from mpflash.logger import log
11
10
 
12
11
  import stubber.utils as utils
12
+ from mpflash.logger import log
13
13
  from stubber.codemod.enrich import enrich_folder
14
+ from stubber.commands.cli import stubber_cli
14
15
  from stubber.freeze.get_frozen import freeze_any
15
16
  from stubber.utils.config import CONFIG
16
17
  from stubber.utils.repos import fetch_repos
17
18
 
18
- from .cli import stubber_cli
19
-
20
19
  ##########################################################################################
21
20
 
22
21
 
@@ -96,19 +95,23 @@ def cli_get_frozen(
96
95
 
97
96
  # first create .pyi files so they can be enriched
98
97
  utils.do_post_processing(stub_paths, stubgen=stubgen, black=False, autoflake=False)
98
+
99
99
  family = "micropython"
100
100
  _version = utils.clean_version(version, drop_v=False, flat=True)
101
101
  docstubs_path = Path(CONFIG.stub_path) / f"{family}-{_version}-docstubs"
102
102
  if docstubs_path.exists():
103
- log.info(f"Enriching {str(stub_path)} with {docstubs_path}")
104
- if merged := enrich_folder(
105
- stub_path,
106
- docstubs_path,
107
- show_diff=False,
108
- write_back=True,
109
- require_docstub=False,
110
- ):
111
- log.info(f"Enriched {merged} frozen modules from docstubs")
103
+ board_folders = [f.parent for f in list(stub_path.glob("**/modules.json"))]
104
+ for folder in board_folders:
105
+ log.info(f"Enriching {str(stub_path)} with {docstubs_path}")
106
+ if merged := enrich_folder(
107
+ docstubs_path,
108
+ folder,
109
+ show_diff=False,
110
+ write_back=True,
111
+ require_docstub=False,
112
+ ext = ".pyi",
113
+ ):
114
+ log.info(f" > Enriched {merged} frozen modules.")
112
115
  else:
113
116
  log.info(f"No docstubs found at {docstubs_path}")
114
117
 
@@ -6,21 +6,21 @@
6
6
 
7
7
 
8
8
  from typing import List
9
+
9
10
  import rich_click as click
10
11
  from mpflash.logger import log
11
12
 
12
13
  from stubber.bulk.mcu_stubber import stub_connected_mcus
14
+ from stubber.commands.cli import stubber_cli
13
15
  from stubber.utils.config import CONFIG
14
16
 
15
- from .cli import stubber_cli
16
-
17
17
  ##########################################################################################
18
18
  # log = logging.getLogger("stubber")
19
19
  #########################################################################################
20
20
 
21
21
 
22
22
  @stubber_cli.command(
23
- name="get-mcu-stubs",
23
+ name="mcu-stubs",
24
24
  aliases=["get-mcu-stubs", "mcu-stubs", "mcu"],
25
25
  )
26
26
  @click.option(
@@ -7,12 +7,11 @@ from typing import List, Union
7
7
  import rich_click as click
8
8
  from mpflash.logger import log
9
9
 
10
+ from stubber.commands.cli import stubber_cli
10
11
  from stubber.publish.merge_docstubs import merge_all_docstubs
11
12
  from stubber.publish.package import GENERIC_L
12
13
  from stubber.utils.config import CONFIG
13
14
 
14
- from .cli import stubber_cli
15
-
16
15
 
17
16
  @stubber_cli.command(name="merge")
18
17
  @click.option("--family", default="micropython", type=str, show_default=True)
@@ -6,7 +6,8 @@ from typing import List, Union
6
6
 
7
7
  import rich_click as click
8
8
  from mpflash.logger import log
9
- from tabulate import tabulate
9
+ from rich.console import Console
10
+ from rich.table import Table
10
11
 
11
12
  from stubber.commands.cli import stubber_cli
12
13
  from stubber.publish.defaults import GENERIC_U
@@ -81,7 +82,7 @@ def cli_publish(
81
82
  versions: Union[str, List[str]],
82
83
  ports: Union[str, List[str]],
83
84
  boards: Union[str, List[str]],
84
- production: bool = True,
85
+ production: bool = False,
85
86
  build: bool = False,
86
87
  force: bool = False,
87
88
  dry_run: bool = False,
@@ -100,7 +101,6 @@ def cli_publish(
100
101
  "Multiple versions are not supported yet\n See https://github.com/Josverl/micropython-stubber/issues/487"
101
102
  )
102
103
 
103
- # db = get_database(publish_path=CONFIG.publish_path, production=production)
104
104
  destination = "pypi" if production else "test-pypi"
105
105
  log.info(f"Publish {family} {versions} {ports} {boards} to {destination}")
106
106
 
@@ -115,4 +115,19 @@ def cli_publish(
115
115
  dry_run=dry_run,
116
116
  clean=clean,
117
117
  )
118
- log.info(tabulate(results, headers="keys"))
118
+ console = Console()
119
+
120
+ if not results:
121
+ console.print("No results to publish")
122
+ return
123
+
124
+ table = Table(show_header=True, header_style="bold magenta", title="Publish Results")
125
+ headers = results[0].keys()
126
+ for header in headers:
127
+ table.add_column(header)
128
+
129
+ for result in results:
130
+ if result["result"] != "-":
131
+ table.add_row(*[str(result[header]) for header in headers])
132
+
133
+ console.print(table)
@@ -4,16 +4,16 @@
4
4
  # stub
5
5
  ##########################################################################################
6
6
 
7
- from mpflash.logger import log
8
7
  from pathlib import Path
9
8
  from typing import Union
10
9
 
11
10
  import rich_click as click
11
+ from mpflash.logger import log
12
+
13
+ from stubber.commands.cli import stubber_cli
12
14
  from stubber.utils import generate_pyi_files
13
15
  from stubber.utils.post import do_post_processing
14
16
 
15
- from .cli import stubber_cli
16
-
17
17
  ##########################################################################################
18
18
  # log = logging.getLogger("stubber")
19
19
  #########################################################################################
@@ -6,13 +6,11 @@ from pathlib import Path
6
6
  from typing import Optional, Union
7
7
 
8
8
  import rich_click as click
9
+ from mpflash.versions import SET_PREVIEW, V_PREVIEW, micropython_versions
9
10
 
10
- import mpflash.basicgit as git
11
+ from stubber.commands.cli import stubber_cli
11
12
  from stubber.utils.config import CONFIG
12
13
  from stubber.utils.repos import fetch_repos, repo_paths
13
- from mpflash.versions import SET_PREVIEW, V_PREVIEW
14
-
15
- from .cli import stubber_cli
16
14
 
17
15
  ##########################################################################################
18
16
  # log = logging.getLogger("stubber")
@@ -22,7 +20,7 @@ from .cli import stubber_cli
22
20
  # get version list from Git tags in the repo that is provided on the command line
23
21
 
24
22
  try:
25
- VERSION_LIST = git.get_tags("micropython/micropython", minver="v1.9.3") + [
23
+ VERSION_LIST = micropython_versions(minver="v1.9.3") + [
26
24
  V_PREVIEW,
27
25
  "latest",
28
26
  "stable",
@@ -4,11 +4,11 @@ from pathlib import Path
4
4
 
5
5
  import rich_click as click
6
6
  from mpflash.logger import log
7
+
8
+ import stubber
9
+ from stubber.commands.cli import stubber_cli
7
10
  from stubber.utils.config import CONFIG
8
11
  from stubber.variants import create_variants
9
- import stubber
10
-
11
- from .cli import stubber_cli
12
12
 
13
13
 
14
14
  @click.option(