def property(load_group_or_method: Union[Callable[[Any], Any], Any]) -> Union[property, Callable[[Callable[[Any], Any]], property]]:
# Default behavior when no load group is provided. Set the load group to the method name.
if isinstance(load_group_or_method, Callable) and not isinstance(load_group_or_method, type):
method = load_group_or_method
load_group = method.__name__
method._Ghost__load_group = load_group
# Set the load group as provided in the decorator
else:
load_group = load_group_or_method
# The load_group and method variables need to be set correctly before this function defintion.
def decorator(method: Callable) -> property:
method._Ghost__load_group = load_group
prop = Ghost.__property(method)
prop._Ghost__load_group = load_group
return prop
if isinstance(load_group_or_method, Callable) and not isinstance(load_group_or_method, type):
return decorator(method)
else:
return decorator
评论列表
文章目录