def has_unparsable_defaults(sig: inspect.Signature) -> bool:
"""Return whether or not the reprs for all defaults in the signature are valid python expressions"""
for param in sig.parameters.values():
if param.default is inspect.Parameter.empty:
continue
try:
parser.expr(repr(param.default))
except SyntaxError:
return True
return False
评论列表
文章目录