micropython-stubber 1.24.0__py3-none-any.whl → 1.24.2__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 (39) hide show
  1. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/METADATA +3 -2
  2. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/RECORD +38 -36
  3. mpflash/mpflash/bootloader/activate.py +1 -1
  4. mpflash/mpflash/flash/esp.py +1 -1
  5. mpflash/mpflash/flash/uf2/__init__.py +18 -2
  6. mpflash/mpflash/mpboard_id/add_boards.py +5 -2
  7. mpflash/mpflash/mpboard_id/board_id.py +7 -5
  8. mpflash/mpflash/mpboard_id/board_info.zip +0 -0
  9. mpflash/mpflash/vendor/pico-universal-flash-nuke/LICENSE.txt +21 -0
  10. mpflash/mpflash/vendor/pico-universal-flash-nuke/universal_flash_nuke.uf2 +0 -0
  11. mpflash/mpflash/vendor/readme.md +2 -0
  12. mpflash/poetry.lock +754 -488
  13. mpflash/pyproject.toml +1 -1
  14. stubber/__init__.py +1 -1
  15. stubber/board/createstubs.py +44 -38
  16. stubber/board/createstubs_db.py +17 -12
  17. stubber/board/createstubs_db_min.py +63 -63
  18. stubber/board/createstubs_db_mpy.mpy +0 -0
  19. stubber/board/createstubs_mem.py +17 -12
  20. stubber/board/createstubs_mem_min.py +99 -99
  21. stubber/board/createstubs_mem_mpy.mpy +0 -0
  22. stubber/board/createstubs_min.py +111 -112
  23. stubber/board/createstubs_mpy.mpy +0 -0
  24. stubber/board/modulelist.txt +27 -27
  25. stubber/codemod/enrich.py +4 -6
  26. stubber/codemod/merge_docstub.py +10 -10
  27. stubber/codemod/visitors/type_helpers.py +182 -0
  28. stubber/commands/get_docstubs_cmd.py +5 -6
  29. stubber/cst_transformer.py +2 -1
  30. stubber/merge_config.py +3 -0
  31. stubber/publish/merge_docstubs.py +1 -2
  32. stubber/publish/stubpackage.py +36 -14
  33. stubber/rst/lookup.py +3 -0
  34. stubber/rst/reader.py +8 -13
  35. stubber/tools/manifestfile.py +2 -1
  36. stubber/codemod/visitors/typevars.py +0 -200
  37. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/LICENSE +0 -0
  38. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/WHEEL +0 -0
  39. {micropython_stubber-1.24.0.dist-info → micropython_stubber-1.24.2.dist-info}/entry_points.txt +0 -0
@@ -1,21 +1,20 @@
1
- A1='windows'
2
- A0='No report file'
3
- z='Failed to create the report.'
4
- y='{}/{}'
5
- x='logging'
6
- w='sys'
7
- v='method'
8
- u='function'
9
- t='bool'
10
- s='str'
11
- r='float'
12
- q='int'
13
- p='stubber'
14
- o=Exception
15
- n=KeyError
16
- m=sorted
17
- l=NotImplementedError
18
- h='pycom'
1
+ A0='windows'
2
+ z='No report file'
3
+ y='Failed to create the report.'
4
+ x='{}/{}'
5
+ w='logging'
6
+ v='sys'
7
+ u='method'
8
+ t='function'
9
+ s='bool'
10
+ r='str'
11
+ q='float'
12
+ p='int'
13
+ o='stubber'
14
+ n=Exception
15
+ m=KeyError
16
+ l=sorted
17
+ k=NotImplementedError
19
18
  g='unix'
20
19
  f=',\n'
21
20
  e='dict'
@@ -39,9 +38,9 @@ L='port'
39
38
  K='.'
40
39
  I=AttributeError
41
40
  H=False
42
- G='/'
43
- E=OSError
44
- D=None
41
+ G=None
42
+ E='/'
43
+ D=OSError
45
44
  C='version'
46
45
  B=''
47
46
  import gc as F,os,sys
@@ -50,10 +49,11 @@ try:from ujson import dumps
50
49
  except:from json import dumps
51
50
  try:from machine import reset
52
51
  except N:pass
53
- try:from collections import OrderedDict as i
54
- except N:from ucollections import OrderedDict as i
52
+ try:from collections import OrderedDict as h
53
+ except N:from ucollections import OrderedDict as h
55
54
  __version__='v1.24.0'
56
- A2=2
55
+ A1=2
56
+ A2=44
57
57
  A3=2
58
58
  A7=['lib','/lib','/sd/lib','/flash/lib',K]
59
59
  class J:
@@ -70,13 +70,13 @@ class J:
70
70
  if A.level<=J.WARNING:A.prnt('WARN :',msg)
71
71
  def error(A,msg):
72
72
  if A.level<=J.ERROR:A.prnt('ERROR :',msg)
73
- A=J.getLogger(p)
73
+ A=J.getLogger(o)
74
74
  J.basicConfig(level=J.INFO)
75
75
  class Stubber:
76
- def __init__(B,path=D,firmware_id=D):
76
+ def __init__(B,path=B,firmware_id=B):
77
77
  C=firmware_id
78
78
  try:
79
- if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise l('MicroPython 1.13.0 cannot be stubbed')
79
+ if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise k('MicroPython 1.13.0 cannot be stubbed')
80
80
  except I:pass
81
81
  B.info=_info();A.info('Port: {}'.format(B.info[L]));A.info('Board: {}'.format(B.info[T]));F.collect()
82
82
  if C:B._fwid=C.lower()
@@ -84,12 +84,12 @@ class Stubber:
84
84
  else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
85
85
  B._start_free=F.mem_free()
86
86
  if path:
87
- if path.endswith(G):path=path[:-1]
87
+ if path.endswith(E):path=path[:-1]
88
88
  else:path=get_root()
89
- B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',G)
90
- try:X(path+G)
91
- except E:A.error('error creating stub folder {}'.format(path))
92
- B.problematic=['upip','upysh','webrepl_setup','http_client','http_client_ssl','http_server','http_server_ssl'];B.excluded=['webrepl','_webrepl','port_diag','example_sub_led.py','example_pub_button.py'];B.modules=[];B._json_name=D;B._json_first=H
89
+ B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',E)
90
+ try:X(path+E)
91
+ except D:A.error('error creating stub folder {}'.format(path))
92
+ B.problematic=['upip','upysh','webrepl_setup','http_client','http_client_ssl','http_server','http_server_ssl'];B.excluded=['webrepl','_webrepl','port_diag','example_sub_led.py','example_pub_button.py'];B.modules=[];B._json_name=G;B._json_first=H
93
93
  def get_obj_attributes(L,item_instance):
94
94
  H=item_instance;C=[];K=[]
95
95
  for A in M(H):
@@ -98,15 +98,15 @@ class Stubber:
98
98
  D=getattr(H,A)
99
99
  try:E=Z(type(D)).split("'")[1]
100
100
  except O:E=B
101
- if E in{q,r,s,t,c,d,e}:G=1
102
- elif E in{u,v}:G=2
101
+ if E in{p,q,r,s,c,d,e}:G=1
102
+ elif E in{t,u}:G=2
103
103
  elif E in'class':G=3
104
104
  else:G=4
105
105
  C.append((A,Z(D),Z(type(D)),D,G))
106
106
  except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
107
107
  except MemoryError as J:Q('MemoryError: {}'.format(J));sleep(1);reset()
108
- C=m([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
109
- def add_modules(A,modules):A.modules=m(set(A.modules)|set(modules))
108
+ C=l([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
109
+ def add_modules(A,modules):A.modules=l(set(A.modules)|set(modules))
110
110
  def create_all_stubs(B):
111
111
  A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
112
112
  for C in B.modules:B.create_one_stub(C)
@@ -115,31 +115,31 @@ class Stubber:
115
115
  B=module_name
116
116
  if B in C.problematic:A.warning('Skip module: {:<25} : Known problematic'.format(B));return H
117
117
  if B in C.excluded:A.warning('Skip module: {:<25} : Excluded'.format(B));return H
118
- I='{}/{}.pyi'.format(C.path,B.replace(K,G));F.collect();D=H
119
- try:D=C.create_module_stub(B,I)
120
- except E:return H
121
- F.collect();return D
122
- def create_module_stub(J,module_name,file_name=D):
118
+ I='{}/{}.pyi'.format(C.path,B.replace(K,E));F.collect();G=H
119
+ try:G=C.create_module_stub(B,I)
120
+ except D:return H
121
+ F.collect();return G
122
+ def create_module_stub(J,module_name,file_name=G):
123
123
  I=file_name;C=module_name
124
- if I is D:L=C.replace(K,'_')+'.pyi';I=J.path+G+L
125
- else:L=I.split(G)[-1]
126
- if G in C:C=C.replace(G,K)
127
- M=D
128
- try:M=__import__(C,D,D,'*');P=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,P))
124
+ if I is G:L=C.replace(K,'_')+'.pyi';I=J.path+E+L
125
+ else:L=I.split(E)[-1]
126
+ if E in C:C=C.replace(E,K)
127
+ M=G
128
+ try:M=__import__(C,G,G,'*');P=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,P))
129
129
  except N:return H
130
130
  X(I)
131
- with R(I,'w')as O:Q=str(J.info).replace('OrderedDict(',B).replace('})','}');S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,J._fwid,Q,__version__);O.write(S);O.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(O,M,C,B)
131
+ with R(I,'w')as O:Q=str(J.info).replace('OrderedDict(',B).replace('})','}');S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,J._fwid,Q,__version__);O.write(S);O.write('from __future__ import annotations\nfrom typing import Any, Final, Generator\nfrom _typeshed import Incomplete\n\n');J.write_object_stub(O,M,C,B)
132
132
  J.report_add(C,I)
133
- if C not in{'os',w,x,'gc'}:
133
+ if C not in{'os',v,w,'gc'}:
134
134
  try:del M
135
- except(E,n):A.warning('could not del new_module')
135
+ except(D,m):A.warning('could not del new_module')
136
136
  F.collect();return V
137
137
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
138
- Z=' at ...>';Y='generator';X='{0}{1}: {3} = {2}\n';W='bound_method';V='Incomplete';O=in_class;N='Exception';M=object_expr;K=' at ';J=fp;E=indent;F.collect()
138
+ Y=' at ...>';X='{0}{1}: {3} = {2}\n';W='bound_method';V='Incomplete';O=in_class;N='Exception';M=object_expr;K=' at ';J=fp;E=indent;F.collect()
139
139
  if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
140
- a,P=L.get_obj_attributes(M)
140
+ Z,P=L.get_obj_attributes(M)
141
141
  if P:A.error(P)
142
- for(C,H,I,b,g)in a:
142
+ for(C,H,I,a,f)in Z:
143
143
  if C in['classmethod','staticmethod','BaseException',N]:continue
144
144
  if C[0].isdigit():A.warning('NameError: invalid name {}'.format(C));continue
145
145
  if I=="<class 'type'>"and S(E)<=A3*4:
@@ -147,8 +147,8 @@ class Stubber:
147
147
  if R:Q=N
148
148
  D='\n{}class {}({}):\n'.format(E,C,Q)
149
149
  if R:D+=E+' ...\n';J.write(D);continue
150
- J.write(D);L.write_object_stub(J,b,'{0}.{1}'.format(obj_name,C),E+' ',O+1);D=E+' def __init__(self, *argv, **kwargs) -> None:\n';D+=E+' ...\n\n';J.write(D)
151
- elif any(A in I for A in[v,u,'closure']):
150
+ J.write(D);L.write_object_stub(J,a,'{0}.{1}'.format(obj_name,C),E+' ',O+1);D=E+' def __init__(self, *argv, **kwargs) -> None:\n';D+=E+' ...\n\n';J.write(D)
151
+ elif any(A in I for A in[u,t,'closure']):
152
152
  T=V;U=B
153
153
  if O>0:U='self, '
154
154
  if W in I or W in H:D='{}@classmethod\n'.format(E)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(E,C,T)
@@ -157,17 +157,16 @@ class Stubber:
157
157
  elif I=="<class 'module'>":0
158
158
  elif I.startswith("<class '"):
159
159
  G=I[8:-2];D=B
160
- if G in(s,q,r,t,'bytearray','bytes'):
160
+ if G in(r,p,q,s,'bytearray','bytes'):
161
161
  if C.upper()==C:D='{0}{1}: Final[{3}] = {2}\n'.format(E,C,H,G)
162
162
  else:D=X.format(E,C,H,G)
163
- elif G in(e,d,c):f={e:'{}',d:'[]',c:'()'};D=X.format(E,C,f[G],G)
164
- elif G in('object','set','frozenset','Pin',Y):
165
- if G==Y:G='Generator'
166
- D='{0}{1}: {2} ## = {4}\n'.format(E,C,G,I,H)
163
+ elif G in(e,d,c):b={e:'{}',d:'[]',c:'()'};D=X.format(E,C,b[G],G)
164
+ elif G in('object','set','frozenset','Pin'):D='{0}{1}: {2} ## = {4}\n'.format(E,C,G,I,H)
165
+ elif G=='generator':G='Generator';D='{0}def {1}(*args, **kwargs) -> Generator: ## = {4}\n{0} ...\n\n'.format(E,C,G,I,H)
167
166
  else:
168
167
  G=V
169
- if K in H:H=H.split(K)[0]+Z
170
- if K in H:H=H.split(K)[0]+Z
168
+ if K in H:H=H.split(K)[0]+Y
169
+ if K in H:H=H.split(K)[0]+Y
171
170
  D='{0}{1}: {2} ## {3} = {4}\n'.format(E,C,G,I,H)
172
171
  J.write(D)
173
172
  else:J.write("# all other, type = '{0}'\n".format(I));J.write(E+C+' # type: Incomplete\n')
@@ -176,46 +175,46 @@ class Stubber:
176
175
  A=self._fwid;B=' .()/\\:$'
177
176
  for C in B:A=A.replace(C,'_')
178
177
  return A
179
- def clean(C,path=D):
180
- if path is D:path=C.path
178
+ def clean(C,path=B):
179
+ if not path:path=C.path
181
180
  A.info('Clean/remove files in folder: {}'.format(path))
182
- try:os.stat(path);F=os.listdir(path)
183
- except(E,I):return
184
- for G in F:
185
- B=y.format(path,G)
181
+ try:os.stat(path);E=os.listdir(path)
182
+ except(D,I):return
183
+ for F in E:
184
+ B=x.format(path,F)
186
185
  try:os.remove(B)
187
- except E:
186
+ except D:
188
187
  try:C.clean(B);os.rmdir(B)
189
- except E:pass
188
+ except D:pass
190
189
  def report_start(B,filename='modules.json'):
191
- H='firmware';B._json_name=y.format(B.path,filename);B._json_first=V;X(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
190
+ H='firmware';B._json_name=x.format(B.path,filename);B._json_first=V;X(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
192
191
  try:
193
- with R(B._json_name,'w')as G:G.write('{');G.write(dumps({H:B.info})[1:-1]);G.write(f);G.write(dumps({p:{C:__version__},'stubtype':H})[1:-1]);G.write(f);G.write('"modules" :[\n')
194
- except E as I:A.error(z);B._json_name=D;raise I
192
+ with R(B._json_name,'w')as E:E.write('{');E.write(dumps({H:B.info})[1:-1]);E.write(f);E.write(dumps({o:{C:__version__},'stubtype':H})[1:-1]);E.write(f);E.write('"modules" :[\n')
193
+ except D as I:A.error(y);B._json_name=G;raise I
195
194
  def report_add(B,module_name,stub_file):
196
- if not B._json_name:raise o(A0)
195
+ if not B._json_name:raise n(z)
197
196
  try:
198
197
  with R(B._json_name,'a')as C:
199
198
  if not B._json_first:C.write(f)
200
199
  else:B._json_first=H
201
- D='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(D)
202
- except E:A.error(z)
200
+ F='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',E));C.write(F)
201
+ except D:A.error(y)
203
202
  def report_end(B):
204
- if not B._json_name:raise o(A0)
203
+ if not B._json_name:raise n(z)
205
204
  with R(B._json_name,'a')as C:C.write('\n]}')
206
205
  A.info('Path: {}'.format(B.path))
207
206
  def X(path):
208
- B=D=0
207
+ B=F=0
209
208
  while B!=-1:
210
- B=path.find(G,D)
209
+ B=path.find(E,F)
211
210
  if B!=-1:
212
211
  C=path[0]if B==0 else path[:B]
213
212
  try:I=os.stat(C)
214
- except E as F:
215
- if F.args[0]==A2:
213
+ except D as G:
214
+ if G.args[0]in[A1,A2]:
216
215
  try:A.debug('Create folder {}'.format(C));os.mkdir(C)
217
- except E as H:A.error('failed to create folder {}'.format(C));raise H
218
- D=B+1
216
+ except D as H:A.error('failed to create folder {}'.format(C));raise H
217
+ F=B+1
219
218
  def Y(s):
220
219
  C=' on '
221
220
  if not s:return B
@@ -226,42 +225,42 @@ def Y(s):
226
225
  if not W in s:return B
227
226
  A=s.split(W)[1].split(K)[1];return A
228
227
  def _info():
229
- X='ev3-pybricks';V='pycopy';U='win32';S='arch';R='cpu';Q='ver';F='mpy';E='build'
228
+ Z='ev3-pybricks';X='pycom';V='pycopy';U='win32';S='arch';R='cpu';Q='ver';E='mpy';D='build'
230
229
  try:J=sys.implementation[0]
231
230
  except a:J=sys.implementation.name
232
- A=i({P:J,C:B,E:B,Q:B,L:sys.platform,T:'UNKNOWN',R:B,F:B,S:B})
231
+ A=h({P:J,C:B,D:B,Q:B,L:sys.platform,T:'UNKNOWN',R:B,E:B,S:B})
233
232
  if A[L].startswith('pyb'):A[L]='stm32'
234
- elif A[L]==U:A[L]=A1
233
+ elif A[L]==U:A[L]=A0
235
234
  elif A[L]=='linux':A[L]=g
236
235
  try:A[C]=A4(sys.implementation.version)
237
236
  except I:pass
238
- try:K=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[T]=K;A[R]=K.split('with')[-1].strip();A[F]=sys.implementation._mpy if'_mpy'in M(sys.implementation)else sys.implementation.mpy if F in M(sys.implementation)else B
237
+ try:K=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[T]=K;A[R]=K.split('with')[-1].strip();A[E]=sys.implementation._mpy if'_mpy'in M(sys.implementation)else sys.implementation.mpy if E in M(sys.implementation)else B
239
238
  except(I,O):pass
240
239
  A[T]=A5()
241
240
  try:
242
241
  if'uname'in M(os):
243
- A[E]=Y(os.uname()[3])
244
- if not A[E]:A[E]=Y(os.uname()[2])
245
- elif C in M(sys):A[E]=Y(sys.version)
242
+ A[D]=Y(os.uname()[3])
243
+ if not A[D]:A[D]=Y(os.uname()[2])
244
+ elif C in M(sys):A[D]=Y(sys.version)
246
245
  except(I,O,a):pass
247
246
  if A[C]==B and sys.platform not in(g,U):
248
- try:Z=os.uname();A[C]=Z.release
247
+ try:c=os.uname();A[C]=c.release
249
248
  except(O,I,a):pass
250
- for(c,d,e)in[(V,V,'const'),(h,h,'FAT'),(X,'pybricks.hubs','EV3Brick')]:
251
- try:f=__import__(d,D,D,e);A[P]=c;del f;break
252
- except(N,n):pass
253
- if A[P]==X:A['release']='2.0.0'
249
+ for(d,e,f)in[(V,V,'const'),(X,X,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
250
+ try:i=__import__(e,G,G,f);A[P]=d;del i;break
251
+ except(N,m):pass
252
+ if A[P]==Z:A['release']='2.0.0'
254
253
  if A[P]==b:
255
254
  A[C]
256
255
  if A[C]and A[C].endswith('.0')and A[C]>='1.10.0'and A[C]<='1.19.9':A[C]=A[C][:-2]
257
- if F in A and A[F]:
258
- G=int(A[F])
259
- try:H=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin','rv32imc'][G>>10]
256
+ if E in A and A[E]:
257
+ F=int(A[E])
258
+ try:H=[G,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin','rv32imc'][F>>10]
260
259
  except O:H='unknown'
261
260
  if H:A[S]=H
262
- A[F]='v{}.{}'.format(G&255,G>>8&3)
263
- if A[E]and not A[C].endswith(W):A[C]=A[C]+W
264
- A[Q]=f"{A[C]}-{A[E]}"if A[E]else f"{A[C]}";return A
261
+ A[E]='v{}.{}'.format(F&255,F>>8&3)
262
+ if A[D]and not A[C].endswith(W):A[C]=A[C]+W
263
+ A[Q]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
265
264
  def A4(version):
266
265
  A=version;B=K.join([str(A)for A in A[:3]])
267
266
  if S(A)>3 and A[3]:B+=U+A[3]
@@ -272,31 +271,31 @@ def A5():
272
271
  return C
273
272
  def get_root():
274
273
  try:A=os.getcwd()
275
- except(E,I):A=K
274
+ except(D,I):A=K
276
275
  B=A
277
- for B in['/remote','/sd','/flash',G,A,K]:
276
+ for B in['/remote','/sd','/flash',E,A,K]:
278
277
  try:C=os.stat(B);break
279
- except E:continue
278
+ except D:continue
280
279
  return B
281
280
  def A6(filename):
282
281
  try:
283
282
  if os.stat(filename)[0]>>14:return V
284
283
  return H
285
- except E:return H
286
- def j():Q("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
284
+ except D:return H
285
+ def i():Q("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
287
286
  def read_path():
288
287
  path=B
289
288
  if S(sys.argv)==3:
290
289
  A=sys.argv[1].lower()
291
290
  if A in('--path','-p'):path=sys.argv[2]
292
- else:j()
293
- elif S(sys.argv)==2:j()
291
+ else:i()
292
+ elif S(sys.argv)==2:i()
294
293
  return path
295
- def k():
296
- try:A=bytes('abc',encoding='utf8');B=k.__module__;return H
297
- except(l,I):return V
298
- 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','builtins','cc3200','cmath','collections','crypto','cryptolib','curl','deflate','dht','display','display_driver_utils','ds18x20','embed','encoder','errno','esp','esp32','esp8266','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',x,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','marshal','math','microWebSocket','microWebSrv','microWebTemplate',b,'mimxrt','mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','nrf','ntptime','onewire','openamp','os','pcf85063a','pic16bit','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform','powerpc','pyb',h,'pye','qemu','qrcode','queue','random','renesas','renesas-ra','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','stm32','struct',w,'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',g,'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','webassembly','websocket','websocket_helper',A1,'wipy','writer','xpt2046','ymodem','zephyr','zlib'];F.collect();stubber.create_all_stubs()
299
- if __name__=='__main__'or k():
294
+ def j():
295
+ try:A=bytes('abc',encoding='utf8');B=j.__module__;return H
296
+ except(k,I):return V
297
+ def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_asyncio','_boot_fat','_espnow','_onewire','_rp2','_thread','_uasyncio','abc','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','base64','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','builtins','cc3200','cmath','collections','collections/__init__','collections/defaultdict','copy','crypto','cryptolib','curl','datetime','deflate','dht','display','display_driver_utils','ds18x20','embed','encoder','errno','esp','esp32','esp8266','espidf','espnow','ffi','flashbdev','fnmatch','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','gzip','hashlib','heapq','hmac','html/__init__','hub75','ili9341','ili9XXX','imagetools','inisetup','inspect','interstate75','io','itertools','jpegdec','js','jsffi','json','lcd160cr','locale','lodepng',w,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','marshal','math','microWebSocket','microWebSrv','microWebTemplate',b,'mimxrt','mip','mip/__init__','mip/__main__','motor','mpu6500','mpu9250','neopixel','network','nrf','ntptime','onewire','openamp','operator','os','os/__init__','os/path','pathlib','pcf85063a','pic16bit','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform','powerpc','pyb','pye','pyscript','pyscript/__init__','pyscript/fs','qemu','qrcode','random','renesas','renesas-ra','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stat','stm','stm32','string','struct',v,'tarfile/__init__','tarfile/write','termios','time','tls','tpcalib','types','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','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','unittest/__init__',g,'uos','uplatform','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','uu','uwebsocket','uzlib',C,'vfs','webassembly','websocket','websocket_helper',A0,'wipy','writer','xpt2046','ymodem','zephyr','zlib'];F.collect();stubber.create_all_stubs()
298
+ if __name__=='__main__'or j():
300
299
  if not A6('no_auto_stubber.txt'):
301
300
  Q(f"createstubs.py: {__version__}")
302
301
  try:F.threshold(4096);F.enable()
Binary file
@@ -1,35 +1,13 @@
1
1
  # list of modules to stub used by the memory optimised createstubs_mem.py
2
2
  WM8960
3
- _OTA
4
3
  _asyncio
5
4
  _boot_fat
6
- _coap
7
5
  _espnow
8
- _flash_control_OTA
9
- _main_pybytes
10
- _mqtt
11
- _mqtt_core
12
- _msg_handl
13
6
  _onewire
14
- _periodical_pin
15
- _pybytes
16
- _pybytes_ca
17
- _pybytes_config
18
- _pybytes_config_reader
19
- _pybytes_connection
20
- _pybytes_constants
21
- _pybytes_debug
22
- _pybytes_library
23
- _pybytes_machine_learning
24
- _pybytes_main
25
- _pybytes_protocol
26
- _pybytes_pyconfig
27
- _pybytes_pymesh_config
28
7
  _rp2
29
- _terminal
30
8
  _thread
31
9
  _uasyncio
32
- _urequest
10
+ abc
33
11
  adcfft
34
12
  aioble/__init__
35
13
  aioble/central
@@ -52,6 +30,7 @@ asyncio/event
52
30
  asyncio/funcs
53
31
  asyncio/lock
54
32
  asyncio/stream
33
+ base64
55
34
  binascii
56
35
  bluetooth
57
36
  breakout_as7262
@@ -81,9 +60,13 @@ builtins
81
60
  cc3200
82
61
  cmath
83
62
  collections
63
+ collections/__init__
64
+ collections/defaultdict
65
+ copy
84
66
  crypto
85
67
  cryptolib
86
68
  curl
69
+ datetime
87
70
  deflate
88
71
  dht
89
72
  display
@@ -99,6 +82,7 @@ espidf
99
82
  espnow
100
83
  ffi
101
84
  flashbdev
85
+ fnmatch
102
86
  framebuf
103
87
  freesans20
104
88
  fs_driver
@@ -107,20 +91,26 @@ galactic
107
91
  gc
108
92
  gfx_pack
109
93
  gsm
94
+ gzip
110
95
  hashlib
111
96
  heapq
97
+ hmac
98
+ html/__init__
112
99
  hub75
113
100
  ili9341
114
101
  ili9XXX
115
102
  imagetools
116
103
  inisetup
104
+ inspect
117
105
  interstate75
118
106
  io
107
+ itertools
119
108
  jpegdec
120
109
  js
121
110
  jsffi
122
111
  json
123
112
  lcd160cr
113
+ locale
124
114
  lodepng
125
115
  logging
126
116
  lsm6dsox
@@ -148,7 +138,11 @@ nrf
148
138
  ntptime
149
139
  onewire
150
140
  openamp
141
+ operator
151
142
  os
143
+ os/__init__
144
+ os/path
145
+ pathlib
152
146
  pcf85063a
153
147
  pic16bit
154
148
  picoexplorer
@@ -164,11 +158,12 @@ plasma
164
158
  platform
165
159
  powerpc
166
160
  pyb
167
- pycom
168
161
  pye
162
+ pyscript
163
+ pyscript/__init__
164
+ pyscript/fs
169
165
  qemu
170
166
  qrcode
171
- queue
172
167
  random
173
168
  renesas
174
169
  renesas-ra
@@ -183,14 +178,19 @@ socket
183
178
  ssd1306
184
179
  ssh
185
180
  ssl
181
+ stat
186
182
  stm
187
183
  stm32
184
+ string
188
185
  struct
189
186
  sys
187
+ tarfile/__init__
188
+ tarfile/write
190
189
  termios
191
190
  time
192
191
  tls
193
192
  tpcalib
193
+ types
194
194
  uarray
195
195
  uasyncio/__init__
196
196
  uasyncio/core
@@ -202,7 +202,6 @@ uasyncio/tasks
202
202
  ubinascii
203
203
  ubluetooth
204
204
  ucollections
205
- ucrypto
206
205
  ucryptolib
207
206
  uctypes
208
207
  uerrno
@@ -225,10 +224,10 @@ umachine
225
224
  umqtt/__init__
226
225
  umqtt/robust
227
226
  umqtt/simple
227
+ unittest/__init__
228
228
  unix
229
229
  uos
230
230
  uplatform
231
- uqueue
232
231
  urandom
233
232
  ure
234
233
  urequests
@@ -247,6 +246,7 @@ usys
247
246
  utelnetserver
248
247
  utime
249
248
  utimeq
249
+ uu
250
250
  uwebsocket
251
251
  uzlib
252
252
  version
stubber/codemod/enrich.py CHANGED
@@ -11,15 +11,13 @@ from pathlib import Path
11
11
  from typing import Any, Dict, List, Optional, Tuple # noqa: UP035
12
12
 
13
13
  from libcst import ParserSyntaxError
14
- from libcst.codemod import CodemodContext, diff_code, exec_transform_with_prettyprint
14
+ from libcst.codemod import (CodemodContext, diff_code,
15
+ exec_transform_with_prettyprint)
15
16
  from libcst.tool import _default_config # type: ignore
16
17
 
17
18
  import stubber.codemod.merge_docstub as merge_docstub
18
19
  from mpflash.logger import log
19
- from stubber.merge_config import (
20
- CP_REFERENCE_TO_DOCSTUB,
21
- copy_type_modules,
22
- )
20
+ from stubber.merge_config import CP_REFERENCE_TO_DOCSTUB, copy_type_modules
23
21
  from stubber.rst.lookup import U_MODULES
24
22
  from stubber.utils.post import run_black
25
23
 
@@ -296,7 +294,7 @@ def enrich_folder(
296
294
  if not source_folder.exists():
297
295
  raise FileNotFoundError(f"Source {source_folder} does not exist")
298
296
  ext = ext or ".py*"
299
- log.info(f"Enrich folder {target_folder}/**/*{ext}")
297
+ log.info(f"Enriching from {source_folder} to {target_folder}/**/*{ext}")
300
298
  count = 0
301
299
 
302
300
  candidates = source_target_candidates(source_folder, target_folder, ext)
@@ -13,8 +13,8 @@ import libcst as cst
13
13
  from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand
14
14
  from libcst.codemod.visitors import AddImportsVisitor, GatherImportsVisitor, ImportItem
15
15
  from libcst.helpers.module import insert_header_comments
16
- from mpflash.logger import log
17
16
 
17
+ from mpflash.logger import log
18
18
  from stubber.cst_transformer import (
19
19
  MODULE_KEY,
20
20
  AnnoValue,
@@ -23,7 +23,7 @@ from stubber.cst_transformer import (
23
23
  update_module_docstr,
24
24
  )
25
25
 
26
- from .visitors.typevars import AddTypeVarsVisitor, GatherTypeVarsVisitor
26
+ from .visitors.type_helpers import AddTypeHelpers, GatherTypeHelpers
27
27
 
28
28
  Mod_Class_T = TypeVar("Mod_Class_T", cst.Module, cst.ClassDef)
29
29
  """TypeVar for Module or ClassDef that both support overloads"""
@@ -95,7 +95,7 @@ class MergeCommand(VisitorBasedCodemodCommand):
95
95
 
96
96
  self.stub_imports: Dict[str, ImportItem] = {}
97
97
  self.all_imports: List[Union[cst.Import, cst.ImportFrom]] = []
98
- self.typevars = []
98
+ self.type_helpers = []
99
99
  # parse the doc-stub file
100
100
  if self.docstub_source:
101
101
  try:
@@ -107,7 +107,7 @@ class MergeCommand(VisitorBasedCodemodCommand):
107
107
  # create the collectors
108
108
  typing_collector = StubTypingCollector()
109
109
  import_collector = GatherImportsVisitor(context)
110
- typevar_collector = GatherTypeVarsVisitor(context)
110
+ typevar_collector = GatherTypeHelpers(context)
111
111
  # visit the source / doc-stub file with all collectors
112
112
  stub_tree.visit(typing_collector)
113
113
  self.annotations = typing_collector.annotations
@@ -116,9 +116,9 @@ class MergeCommand(VisitorBasedCodemodCommand):
116
116
  stub_tree.visit(import_collector)
117
117
  self.stub_imports = import_collector.symbol_mapping
118
118
  self.all_imports = import_collector.all_imports
119
- # Get typevars
119
+ # Get typevars, type aliasses and ParamSpecs
120
120
  stub_tree.visit(typevar_collector)
121
- self.typevars = typevar_collector.all_typealias_or_vars
121
+ self.type_helpers = typevar_collector.all_typehelpers
122
122
 
123
123
  # ------------------------------------------------------------------------
124
124
 
@@ -177,11 +177,11 @@ class MergeCommand(VisitorBasedCodemodCommand):
177
177
  )
178
178
  # --------------------------------------------------------------------
179
179
  # Add any typevars to the module
180
- if self.typevars:
181
- for tv in self.typevars:
182
- AddTypeVarsVisitor.add_typevar(self.context, tv) # type: ignore
180
+ if self.type_helpers:
181
+ for tv in self.type_helpers:
182
+ AddTypeHelpers.add_typevar(self.context, tv) # type: ignore
183
183
 
184
- atv = AddTypeVarsVisitor(self.context)
184
+ atv = AddTypeHelpers(self.context)
185
185
  updated_node = atv.transform_module(updated_node)
186
186
 
187
187
  # --------------------------------------------------------------------