code: def extras_to_string(extras):
      # type: (Iterable[S]) -> S
      
      if isinstance(extras, six.string_types):
          if extras.startswith("["):
              return extras
          else:
              extras = [extras]
      if not extras:
          return ""
      return "[{0}]".format(",".join(sorted(set(extras))))
docs: Turn a list of extras into a string