Skip to content

Commit

Permalink
优化对构造函数的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Jul 23, 2023
1 parent a4bc2cc commit 85987b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions unitauto/methodutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ def get_instance(
clazz, value: any = null, constructor: callable = null, class_args: list = null,
reuse: bool = false, module=null, import_fun: callable = null
):
key = str(clazz) + ('' if is_empty(constructor) else '.' + str(constructor))\
+ '(' + str(class_args) + ')' if reuse else null
reuse = reuse or false
key = str(clazz) + ('' if is_none(constructor) else '.' + str(constructor))\
+ '(' + str(class_args) + ')' if reuse else null

instance = INSTANCE_MAP[key] if reuse else null

Expand Down Expand Up @@ -669,9 +670,8 @@ def final_callback(*args, **kwargs):
elif static:
func = getattr(cls, method)
else:
constructor_func = None if constructor is None else getattr(module, constructor)

if instance is None:
constructor_func = None if is_empty(constructor) else getattr(module, constructor)
instance = getinstance(
cls, null, constructor_func, class_args, reuse=reuse, module=module, import_fun=import_fun
)
Expand Down

0 comments on commit 85987b4

Please sign in to comment.