File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616import ast
1717from enum import Enum
18+ import functools
1819import inspect
1920from inspect import Parameter
2021from pathlib import Path
@@ -398,9 +399,10 @@ def get_ast_tree(cls):
398399 for item in tree .body :
399400 if isinstance (item , ast .ClassDef ) and item .name == cls .__name__ :
400401 return item
401- raise ValueError ("Cannot find {cls.__name__} in ast" )
402+ raise ValueError (f "Cannot find { cls .__name__ } in ast" )
402403
403404
405+ @functools .lru_cache
404406def get_ast_mro_trees (cls ):
405407 return [get_ast_tree (c ) for c in cls .__mro__ if c .__module__ != "builtins" ]
406408
@@ -432,11 +434,11 @@ def update_sig_from_node(node, sig):
432434 params = dict (sig .parameters )
433435 args = node .args
434436 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 ,
440442 )
441443 for param in allargs :
442444 if param is None :
You can’t perform that action at this time.
0 commit comments