def _get_pat_and_asc(ctx, binding):
if isinstance(binding, ast.Subscript):
value = binding.value
if isinstance(value, ast.Name) and value.id == 'let':
slice = binding.slice
if isinstance(slice, ast.Index):
return (slice.value, None)
elif isinstance(slice, ast.Slice):
lower, upper, step = slice.lower, slice.upper, slice.step
if lower is not None and upper is not None and step is None:
asc = typy._process_asc_ast(ctx, upper)
return lower, asc
else:
raise _errors.TyError("Invalid ascription format.", slice)
else:
raise _errors.TyError("Invalid ascription format.", slice)
else:
raise _errors.TyError("Invalid with format.", value)
else:
raise _errors.TyError("Invalid with format.", binding)
评论列表
文章目录