File tree 2 files changed +48
-2
lines changed 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -213,8 +213,8 @@ check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
213
213
$(PYTHON ) tools/check_translations.py $^
214
214
215
215
stubs :
216
- rst2pyi $( VALIDATE ) shared-bindings/ $(STUBDIR )
217
- python setup.py sdist
216
+ python tools/extract_pyi.py shared-bindings/ $(STUBDIR )
217
+ # python setup.py sdist
218
218
219
219
update-frozen-libraries :
220
220
@echo " Updating all frozen libraries to latest tagged version."
Original file line number Diff line number Diff line change
1
+ import os
2
+ import sys
3
+ import astroid
4
+ import traceback
5
+
6
+ top_level = sys .argv [1 ].strip ("/" )
7
+ stub_directory = sys .argv [2 ]
8
+
9
+ if top_level .count ("/" ) == 1 :
10
+ top_level , module = top_level .split ("/" )
11
+ modules = [module ]
12
+ else :
13
+ modules = os .listdir (top_level )
14
+ modules = sorted (modules )
15
+
16
+ ok = 0
17
+ total = 0
18
+ for module in modules :
19
+ module_path = os .path .join (top_level , module )
20
+ if not os .path .isdir (module_path ):
21
+ continue
22
+ pyi_lines = []
23
+ for class_file in os .listdir (module_path ):
24
+ class_path = os .path .join (module_path , class_file )
25
+ with open (class_path , "r" ) as f :
26
+ for line in f :
27
+ if line .startswith ("//| " ):
28
+ pyi_lines .append (line [4 :])
29
+
30
+ stub_filename = os .path .join (stub_directory , module + ".pyi" )
31
+ print (stub_filename )
32
+ stub_contents = "" .join (pyi_lines )
33
+ with open (stub_filename , "w" ) as f :
34
+ f .write (stub_contents )
35
+
36
+ # Validate that the module is a parseable stub.
37
+ total += 1
38
+ try :
39
+ astroid .parse (stub_contents )
40
+ ok += 1
41
+ except astroid .exceptions .AstroidSyntaxError as e :
42
+ e = e .__cause__
43
+ traceback .print_exception (type (e ), e , e .__traceback__ )
44
+ print ()
45
+
46
+ print (f"{ ok } ok out of { total } " )
You can’t perform that action at this time.
0 commit comments