import ast


def dotted_name_to_ast(dotted_name: str) -> ast.AST:
  """Converts a dotted name to an ast.Attribute."""
  pieces = dotted_name.split('.')
  result = ast.Name(pieces[0], ctx=ast.Load())
  for piece in pieces[1:]:
    result = ast.Attribute(value=result, attr=piece, ctx=ast.Load())
  return result