File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 15
15
16
16
import ast
17
17
from enum import Enum
18
+ import functools
18
19
import inspect
19
20
from inspect import Parameter
20
21
from pathlib import Path
@@ -398,9 +399,10 @@ def get_ast_tree(cls):
398
399
for item in tree .body :
399
400
if isinstance (item , ast .ClassDef ) and item .name == cls .__name__ :
400
401
return item
401
- raise ValueError ("Cannot find {cls.__name__} in ast" )
402
+ raise ValueError (f "Cannot find { cls .__name__ } in ast" )
402
403
403
404
405
+ @functools .lru_cache
404
406
def get_ast_mro_trees (cls ):
405
407
return [get_ast_tree (c ) for c in cls .__mro__ if c .__module__ != "builtins" ]
406
408
@@ -432,11 +434,11 @@ def update_sig_from_node(node, sig):
432
434
params = dict (sig .parameters )
433
435
args = node .args
434
436
allargs = (
435
- args .posonlyargs
436
- + args .args
437
- + [ args .vararg ]
438
- + args .kwonlyargs
439
- + [ args .kwarg ]
437
+ * args .posonlyargs ,
438
+ * args .args ,
439
+ args .vararg ,
440
+ * args .kwonlyargs ,
441
+ args .kwarg ,
440
442
)
441
443
for param in allargs :
442
444
if param is None :
You can’t perform that action at this time.
0 commit comments