code: def get_local_part(value):
      
      local_part = LocalPart()
      leader = None
      if value[0] in CFWS_LEADER:
          leader, value = get_cfws(value)
      if not value:
          raise errors.HeaderParseError(
              "expected local-part but found '{}'".format(value))
      try:
          token, value = get_dot_atom(value)
      except errors.HeaderParseError:
          try:
              token, value = get_word(value)
          except errors.HeaderParseError:
              if value[0] != '\\' and value[0] in PHRASE_ENDS:
                  raise
              token = TokenList()
      if leader is not None:
          token[:0] = [leader]
      local_part.append(token)
      if value and (value[0]=='\\' or value[0] not in PHRASE_ENDS):
          obs_local_part, value = get_obs_local_part(str(local_part) + value)
          if obs_local_part.token_type == 'invalid-obs-local-part':
              local_part.defects.append(errors.InvalidHeaderDefect(
                  "local-part is not dot-atom, quoted-string, or obs-local-part"))
          else:
              local_part.defects.append(errors.ObsoleteHeaderDefect(
                  "local-part is not a dot-atom (contains CFWS)"))
          local_part[0] = obs_local_part
      try:
          local_part.value.encode('ascii')
      except UnicodeEncodeError:
          local_part.defects.append(errors.NonASCIILocalPartDefect(
                  "local-part contains non-ASCII characters)"))
      return local_part, value
docs: local-part = dot-atom / quoted-string / obs-local-part