micropython-stubber 1.23.2__py3-none-any.whl → 1.23.3__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.
@@ -1,35 +1,35 @@
1
- A0='No report file'
2
- z='Failed to create the report.'
3
- y='{}/{}'
4
- x='logging'
5
- w='sys'
6
- v='method'
7
- u='function'
8
- t='bool'
9
- s='str'
10
- r='float'
11
- q='int'
12
- p='stubber'
13
- o=Exception
14
- n=KeyError
15
- m=sorted
16
- l=NotImplementedError
17
- h='pycom'
18
- g=',\n'
19
- f='dict'
20
- e='list'
21
- d='tuple'
22
- c='micropython'
23
- b=TypeError
24
- a=repr
25
- Z=print
26
- W='-preview'
27
- V=True
28
- U='-'
29
- T='board'
30
- S=len
31
- R=open
32
- Q=IndexError
1
+ z='No report file'
2
+ y='Failed to create the report.'
3
+ x='{}/{}'
4
+ w='logging'
5
+ v='sys'
6
+ u='method'
7
+ t='function'
8
+ s='bool'
9
+ r='str'
10
+ q='float'
11
+ p='int'
12
+ o='stubber'
13
+ n=Exception
14
+ m=KeyError
15
+ l=sorted
16
+ k=NotImplementedError
17
+ g='pycom'
18
+ f=',\n'
19
+ e='dict'
20
+ d='list'
21
+ c='tuple'
22
+ b='micropython'
23
+ a=TypeError
24
+ Z=repr
25
+ Y=print
26
+ V='-preview'
27
+ U=True
28
+ T='-'
29
+ S='board'
30
+ R=len
31
+ Q=open
32
+ P=IndexError
33
33
  O='family'
34
34
  N=ImportError
35
35
  M=dir
@@ -48,15 +48,14 @@ try:from ujson import dumps
48
48
  except:from json import dumps
49
49
  try:from machine import reset
50
50
  except N:pass
51
- try:from collections import OrderedDict as i
52
- except N:from ucollections import OrderedDict as i
53
- __version__='v1.23.2'
54
- P=__version__.rsplit(J,1)[0]
51
+ try:from collections import OrderedDict as h
52
+ except N:from ucollections import OrderedDict as h
53
+ __version__='v1.23.3'
54
+ A0=2
55
55
  A1=2
56
- A2=2
57
56
  A5=['lib','/lib','/sd/lib','/flash/lib',J]
58
57
  class L:
59
- INFO=20;WARNING=30;ERROR=40;level=INFO;prnt=Z
58
+ INFO=20;WARNING=30;ERROR=40;level=INFO;prnt=Y
60
59
  @staticmethod
61
60
  def getLogger(name):return L()
62
61
  @classmethod
@@ -67,24 +66,24 @@ class L:
67
66
  if A.level<=L.WARNING:A.prnt('WARN :',msg)
68
67
  def error(A,msg):
69
68
  if A.level<=L.ERROR:A.prnt('ERROR :',msg)
70
- A=L.getLogger(p)
69
+ A=L.getLogger(o)
71
70
  L.basicConfig(level=L.INFO)
72
71
  class Stubber:
73
72
  def __init__(B,path=D,firmware_id=D):
74
73
  C=firmware_id
75
74
  try:
76
- if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise l('MicroPython 1.13.0 cannot be stubbed')
75
+ if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise k('MicroPython 1.13.0 cannot be stubbed')
77
76
  except I:pass
78
- B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[T]));F.collect()
77
+ B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[S]));F.collect()
79
78
  if C:B._fwid=C.lower()
80
- elif B.info[O]==c:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(U)
79
+ elif B.info[O]==b:B._fwid='{family}-v{version}-{port}-{board}'.format(**B.info).rstrip(T)
81
80
  else:B._fwid='{family}-v{version}-{port}'.format(**B.info)
82
81
  B._start_free=F.mem_free()
83
82
  if path:
84
83
  if path.endswith(G):path=path[:-1]
85
84
  else:path=get_root()
86
85
  B.path='{}/stubs/{}'.format(path,B.flat_fwid).replace('//',G)
87
- try:X(path+G)
86
+ try:W(path+G)
88
87
  except E:A.error('error creating stub folder {}'.format(path))
89
88
  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
90
89
  def get_obj_attributes(L,item_instance):
@@ -93,17 +92,17 @@ class Stubber:
93
92
  if A.startswith('__')and not A in L.modules:continue
94
93
  try:
95
94
  D=getattr(H,A)
96
- try:E=a(type(D)).split("'")[1]
97
- except Q:E=B
98
- if E in{q,r,s,t,d,e,f}:G=1
99
- elif E in{u,v}:G=2
95
+ try:E=Z(type(D)).split("'")[1]
96
+ except P:E=B
97
+ if E in{p,q,r,s,c,d,e}:G=1
98
+ elif E in{t,u}:G=2
100
99
  elif E in'class':G=3
101
100
  else:G=4
102
- C.append((A,a(D),a(type(D)),D,G))
101
+ C.append((A,Z(D),Z(type(D)),D,G))
103
102
  except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
104
- except MemoryError as J:Z('MemoryError: {}'.format(J));sleep(1);reset()
105
- C=m([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
106
- def add_modules(A,modules):A.modules=m(set(A.modules)|set(modules))
103
+ except MemoryError as J:Y('MemoryError: {}'.format(J));sleep(1);reset()
104
+ C=l([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
105
+ def add_modules(A,modules):A.modules=l(set(A.modules)|set(modules))
107
106
  def create_all_stubs(B):
108
107
  A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
109
108
  for C in B.modules:B.create_one_stub(C)
@@ -122,15 +121,15 @@ class Stubber:
122
121
  else:L=I.split(G)[-1]
123
122
  if G in C:C=C.replace(G,J)
124
123
  M=D
125
- try:M=__import__(C,D,D,'*');Q=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,Q))
124
+ try:M=__import__(C,D,D,'*');P=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,P))
126
125
  except N:return H
127
- X(I)
128
- with R(I,'w')as O:S=str(K.info).replace('OrderedDict(',B).replace('})','}');T='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,K._fwid,S,P);O.write(T);O.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');K.write_object_stub(O,M,C,B)
126
+ W(I)
127
+ with Q(I,'w')as O:R=str(K.info).replace('OrderedDict(',B).replace('})','}');S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,K._fwid,R,__version__);O.write(S);O.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');K.write_object_stub(O,M,C,B)
129
128
  K.report_add(C,I)
130
- if C not in{'os',w,x,'gc'}:
129
+ if C not in{'os',v,w,'gc'}:
131
130
  try:del M
132
- except(E,n):A.warning('could not del new_module')
133
- F.collect();return V
131
+ except(E,m):A.warning('could not del new_module')
132
+ F.collect();return U
134
133
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
135
134
  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;D=indent;F.collect()
136
135
  if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
@@ -139,13 +138,13 @@ class Stubber:
139
138
  for(E,H,I,b,g)in a:
140
139
  if E in['classmethod','staticmethod','BaseException',N]:continue
141
140
  if E[0].isdigit():A.warning('NameError: invalid name {}'.format(E));continue
142
- if I=="<class 'type'>"and S(D)<=A2*4:
143
- Q=B;R=E.endswith(N)or E.endswith('Error')or E in['KeyboardInterrupt','StopIteration','SystemExit']
144
- if R:Q=N
141
+ if I=="<class 'type'>"and R(D)<=A1*4:
142
+ Q=B;S=E.endswith(N)or E.endswith('Error')or E in['KeyboardInterrupt','StopIteration','SystemExit']
143
+ if S:Q=N
145
144
  C='\n{}class {}({}):\n'.format(D,E,Q)
146
- if R:C+=D+' ...\n';J.write(C);continue
145
+ if S:C+=D+' ...\n';J.write(C);continue
147
146
  J.write(C);L.write_object_stub(J,b,'{0}.{1}'.format(obj_name,E),D+' ',O+1);C=D+' def __init__(self, *argv, **kwargs) -> None:\n';C+=D+' ...\n\n';J.write(C)
148
- elif any(A in I for A in[v,u,'closure']):
147
+ elif any(A in I for A in[u,t,'closure']):
149
148
  T=V;U=B
150
149
  if O>0:U='self, '
151
150
  if W in I or W in H:C='{}@classmethod\n'.format(D)+'{}def {}(cls, *args, **kwargs) -> {}:\n'.format(D,E,T)
@@ -154,8 +153,8 @@ class Stubber:
154
153
  elif I=="<class 'module'>":0
155
154
  elif I.startswith("<class '"):
156
155
  G=I[8:-2];C=B
157
- if G in(s,q,r,t,'bytearray','bytes'):C=X.format(D,E,H,G)
158
- elif G in(f,e,d):c={f:'{}',e:'[]',d:'()'};C=X.format(D,E,c[G],G)
156
+ if G in(r,p,q,s,'bytearray','bytes'):C=X.format(D,E,H,G)
157
+ elif G in(e,d,c):f={e:'{}',d:'[]',c:'()'};C=X.format(D,E,f[G],G)
159
158
  elif G in('object','set','frozenset','Pin',Y):
160
159
  if G==Y:G='Generator'
161
160
  C='{0}{1}: {2} ## = {4}\n'.format(D,E,G,I,H)
@@ -177,29 +176,29 @@ class Stubber:
177
176
  try:os.stat(path);F=os.listdir(path)
178
177
  except(E,I):return
179
178
  for G in F:
180
- B=y.format(path,G)
179
+ B=x.format(path,G)
181
180
  try:os.remove(B)
182
181
  except E:
183
182
  try:C.clean(B);os.rmdir(B)
184
183
  except E:pass
185
184
  def report_start(B,filename='modules.json'):
186
- 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()
185
+ H='firmware';B._json_name=x.format(B.path,filename);B._json_first=U;W(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
187
186
  try:
188
- with R(B._json_name,'w')as G:G.write('{');G.write(dumps({H:B.info})[1:-1]);G.write(g);G.write(dumps({p:{C:P},'stubtype':H})[1:-1]);G.write(g);G.write('"modules" :[\n')
189
- except E as I:A.error(z);B._json_name=D;raise I
187
+ with Q(B._json_name,'w')as G:G.write('{');G.write(dumps({H:B.info})[1:-1]);G.write(f);G.write(dumps({o:{C:__version__},'stubtype':H})[1:-1]);G.write(f);G.write('"modules" :[\n')
188
+ except E as I:A.error(y);B._json_name=D;raise I
190
189
  def report_add(B,module_name,stub_file):
191
- if not B._json_name:raise o(A0)
190
+ if not B._json_name:raise n(z)
192
191
  try:
193
- with R(B._json_name,'a')as C:
194
- if not B._json_first:C.write(g)
192
+ with Q(B._json_name,'a')as C:
193
+ if not B._json_first:C.write(f)
195
194
  else:B._json_first=H
196
195
  D='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(D)
197
- except E:A.error(z)
196
+ except E:A.error(y)
198
197
  def report_end(B):
199
- if not B._json_name:raise o(A0)
200
- with R(B._json_name,'a')as C:C.write('\n]}')
198
+ if not B._json_name:raise n(z)
199
+ with Q(B._json_name,'a')as C:C.write('\n]}')
201
200
  A.info('Path: {}'.format(B.path))
202
- def X(path):
201
+ def W(path):
203
202
  B=D=0
204
203
  while B!=-1:
205
204
  B=path.find(G,D)
@@ -207,57 +206,57 @@ def X(path):
207
206
  C=path[0]if B==0 else path[:B]
208
207
  try:I=os.stat(C)
209
208
  except E as F:
210
- if F.args[0]==A1:
209
+ if F.args[0]==A0:
211
210
  try:os.mkdir(C)
212
211
  except E as H:A.error('failed to create folder {}'.format(C));raise H
213
212
  D=B+1
214
- def Y(s):
213
+ def X(s):
215
214
  C=' on '
216
215
  if not s:return B
217
216
  s=s.split(C,1)[0]if C in s else s
218
217
  if s.startswith('v'):
219
- if not U in s:return B
220
- A=s.split(U)[1];return A
221
- if not W in s:return B
222
- A=s.split(W)[1].split(J)[1];return A
218
+ if not T in s:return B
219
+ A=s.split(T)[1];return A
220
+ if not V in s:return B
221
+ A=s.split(V)[1].split(J)[1];return A
223
222
  def _info():
224
- a='ev3-pybricks';Z='pycopy';X='unix';V='win32';U='arch';S='cpu';R='ver';F='mpy';E='build'
223
+ Z='ev3-pybricks';Y='pycopy';W='unix';U='win32';T='arch';R='cpu';Q='ver';F='mpy';E='build'
225
224
  try:H=sys.implementation[0]
226
- except b:H=sys.implementation.name
227
- A=i({O:H,C:B,E:B,R:B,K:sys.platform,T:'UNKNOWN',S:B,F:B,U:B})
225
+ except a:H=sys.implementation.name
226
+ A=h({O:H,C:B,E:B,Q:B,K:sys.platform,S:'UNKNOWN',R:B,F:B,T:B})
228
227
  if A[K].startswith('pyb'):A[K]='stm32'
229
- elif A[K]==V:A[K]='windows'
230
- elif A[K]=='linux':A[K]=X
231
- try:A[C]=P(sys.implementation.version)
228
+ elif A[K]==U:A[K]='windows'
229
+ elif A[K]=='linux':A[K]=W
230
+ try:A[C]=A2(sys.implementation.version)
232
231
  except I:pass
233
- try:J=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[T]=J;A[S]=J.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
234
- except(I,Q):pass
235
- A[T]=A3()
232
+ try:J=sys.implementation._machine if'_machine'in M(sys.implementation)else os.uname().machine;A[S]=J;A[R]=J.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
233
+ except(I,P):pass
234
+ A[S]=A3()
236
235
  try:
237
236
  if'uname'in M(os):
238
- A[E]=Y(os.uname()[3])
239
- if not A[E]:A[E]=Y(os.uname()[2])
240
- elif C in M(sys):A[E]=Y(sys.version)
241
- except(I,Q,b):pass
242
- if A[C]==B and sys.platform not in(X,V):
243
- try:d=os.uname();A[C]=d.release
244
- except(Q,I,b):pass
245
- for(e,f,g)in[(Z,Z,'const'),(h,h,'FAT'),(a,'pybricks.hubs','EV3Brick')]:
246
- try:j=__import__(f,D,D,g);A[O]=e;del j;break
247
- except(N,n):pass
248
- if A[O]==a:A['release']='2.0.0'
249
- if A[O]==c:
237
+ A[E]=X(os.uname()[3])
238
+ if not A[E]:A[E]=X(os.uname()[2])
239
+ elif C in M(sys):A[E]=X(sys.version)
240
+ except(I,P,a):pass
241
+ if A[C]==B and sys.platform not in(W,U):
242
+ try:c=os.uname();A[C]=c.release
243
+ except(P,I,a):pass
244
+ for(d,e,f)in[(Y,Y,'const'),(g,g,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
245
+ try:i=__import__(e,D,D,f);A[O]=d;del i;break
246
+ except(N,m):pass
247
+ if A[O]==Z:A['release']='2.0.0'
248
+ if A[O]==b:
250
249
  A[C]
251
250
  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]
252
251
  if F in A and A[F]:
253
252
  G=int(A[F]);L=[D,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
254
- if L:A[U]=L
253
+ if L:A[T]=L
255
254
  A[F]='v{}.{}'.format(G&255,G>>8&3)
256
- if A[E]and not A[C].endswith(W):A[C]=A[C]+W
257
- A[R]=f"{A[C]}-{A[E]}"if A[E]else f"{A[C]}";return A
258
- def P(version):
255
+ if A[E]and not A[C].endswith(V):A[C]=A[C]+V
256
+ A[Q]=f"{A[C]}-{A[E]}"if A[E]else f"{A[C]}";return A
257
+ def A2(version):
259
258
  A=version;B=J.join([str(A)for A in A[:3]])
260
- if S(A)>3 and A[3]:B+=U+A[3]
259
+ if R(A)>3 and A[3]:B+=T+A[3]
261
260
  return B
262
261
  def A3():
263
262
  try:from boardname import BOARDNAME as C;A.info('Found BOARDNAME: {}'.format(C))
@@ -273,23 +272,23 @@ def get_root():
273
272
  return B
274
273
  def A4(filename):
275
274
  try:
276
- if os.stat(filename)[0]>>14:return V
275
+ if os.stat(filename)[0]>>14:return U
277
276
  return H
278
277
  except E:return H
279
- def j():Z("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
278
+ def i():Y("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
280
279
  def read_path():
281
280
  path=B
282
- if S(sys.argv)==3:
281
+ if R(sys.argv)==3:
283
282
  A=sys.argv[1].lower()
284
283
  if A in('--path','-p'):path=sys.argv[2]
285
- else:j()
286
- elif S(sys.argv)==2:j()
284
+ else:i()
285
+ elif R(sys.argv)==2:i()
287
286
  return path
288
- def k():
289
- try:A=bytes('abc',encoding='utf8');B=k.__module__;return H
290
- except(l,I):return V
291
- 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',x,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','math','microWebSocket','microWebSrv','microWebTemplate',c,'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',h,'pye','qrcode','queue','random','requests','requests/__init__','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','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','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()
292
- if __name__=='__main__'or k():
287
+ def j():
288
+ try:A=bytes('abc',encoding='utf8');B=j.__module__;return H
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','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
+ if __name__=='__main__'or j():
293
292
  if not A4('no_auto_stubber.txt'):
294
293
  try:F.threshold(4*1024);F.enable()
295
294
  except BaseException:pass
Binary file
stubber/codemod/enrich.py CHANGED
@@ -6,7 +6,6 @@ Both (.py or .pyi) files are supported.
6
6
  from pathlib import Path
7
7
  from typing import Any, Dict, Optional
8
8
 
9
- from libcst import ParserSyntaxError
10
9
  from libcst.codemod import CodemodContext, diff_code, exec_transform_with_prettyprint
11
10
  from libcst.tool import _default_config # type: ignore
12
11
  from mpflash.logger import log
@@ -114,7 +113,6 @@ def enrich_folder(
114
113
  raise FileNotFoundError(f"Source {source_path} does not exist")
115
114
  if not docstub_path.exists():
116
115
  raise FileNotFoundError(f"Docstub {docstub_path} does not exist")
117
- log.debug(f"Enrich folder {source_path}.")
118
116
  count = 0
119
117
  # list all the .py and .pyi files in the source folder
120
118
  if source_path.is_file():
@@ -140,10 +138,6 @@ def enrich_folder(
140
138
  # no docstub to enrich with
141
139
  if require_docstub:
142
140
  raise (FileNotFoundError(f"No doc-stub file found for {source_file}")) from e
143
- except (Exception, ParserSyntaxError) as e:
144
- log.error(f"Error parsing {source_file}")
145
- log.exception(e)
146
- continue
147
141
  # run black on the destination folder
148
142
  run_black(source_path)
149
143
  # DO NOT run Autoflake as this removes some relevant (unused) imports
@@ -66,14 +66,10 @@ def merge_all_docstubs(
66
66
  log.info(f"skipping {merged_path.name}, no MCU stubs found in {board_path}")
67
67
  continue
68
68
  log.info(f"Merge {candidate['version']} docstubs with boardstubs to {merged_path.name}")
69
- try:
70
- result = copy_and_merge_docstubs(board_path, merged_path, doc_path)
71
- # Add methods from docstubs to the MCU stubs that do not exist in the MCU stubs
72
- # Add the __call__ method to the machine.Pin and pyb.Pin class
73
- add_machine_pin_call(merged_path, candidate["version"])
74
- except Exception as e:
75
- log.error(f"Error parsing {candidate['version']} docstubs: {e}")
76
- continue
69
+ result = copy_and_merge_docstubs(board_path, merged_path, doc_path)
70
+ # Add methods from docstubs to the MCU stubs that do not exist in the MCU stubs
71
+ # Add the __call__ method to the machine.Pin and pyb.Pin class
72
+ add_machine_pin_call(merged_path, candidate["version"])
77
73
  if result:
78
74
  merged += 1
79
75
  log.info(f"merged {merged} of {len(candidates)} candidates")
@@ -14,9 +14,9 @@ from mpflash.basicgit import get_git_describe
14
14
  from stubber.publish.helpers import get_module_docstring
15
15
 
16
16
  if sys.version_info >= (3, 11):
17
- import tomllib # type: ignore
17
+ import tomllib # type: ignore
18
18
  else:
19
- import tomli as tomllib # type: ignore
19
+ import tomli as tomllib # type: ignore
20
20
 
21
21
  from typing import NewType
22
22
 
@@ -252,12 +252,8 @@ class Builder(VersionedPackage):
252
252
  pyproject = None
253
253
  _toml = self.toml_path
254
254
  if (_toml).exists():
255
- log.info(f"Load pyproject from {_toml}")
256
- try:
257
- with open(_toml, "rb") as f:
258
- pyproject = tomllib.load(f)
259
- except tomllib.TOMLDecodeError as e:
260
- log.error(f"Could not load pyproject.toml file {e}")
255
+ with open(_toml, "rb") as f:
256
+ pyproject = tomllib.load(f)
261
257
  return pyproject
262
258
 
263
259
  @pyproject.setter
stubber/rst/lookup.py CHANGED
@@ -142,8 +142,6 @@ LOOKUP_LIST = {
142
142
  "pyb.hard_reset": ("NoReturn", 0.95), # never returns
143
143
  "pyb.I2C.recv": ("bytes", 0.95), # complex in docstring
144
144
  "pyb.SPI.recv": ("bytes", 0.95), # complex in docstring
145
- "pyb.hid_keyboard": ("Tuple", 0.95), # ?
146
- "pyb.hid_mouse": ("Tuple", 0.95), # plain wrong
147
145
  "ubluetooth.BLE.irq": ("Any", 0.95), # never returns
148
146
  "uctypes.bytearray_at": ("bytearray", 0.95),
149
147
  "uctypes.bytes_at": ("bytes", 0.95),