def convert(self, value, param, ctx: click.Context) -> t.Optional[bool]:
"""
Convert method that makes this class usable as a click type.
"""
if isinstance(value, self):
return value
elif isinstance(value, str):
value = value.lower()
if value == "true" :
return True
elif value == "false":
return False
elif value == "none":
return None
self.fail("{} is no valid bool or 'none'".format(value), param, ctx)
评论列表
文章目录