Skip to content

Commit 966d185

Browse files
committed
Boilerplate.py review comments
1 parent c9ba7bd commit 966d185

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tools/boilerplate.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import ast
1717
from enum import Enum
18+
import functools
1819
import inspect
1920
from inspect import Parameter
2021
from 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
404406
def 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:

0 commit comments

Comments
 (0)