code: def from_string(cls, string, relpath=None, encoding=None, is_sass=None):
          
          if isinstance(string, six.text_type):
              # Already decoded; we don't know what encoding to use for output,
              # though, so still check for a @charset.
              # TODO what if the given encoding conflicts with the one in the
              # file?  do we care?
              if encoding is None:
                  encoding = determine_encoding(string)
  
              byte_contents = string.encode(encoding)
              text_contents = string
          elif isinstance(string, six.binary_type):
              encoding = determine_encoding(string)
              byte_contents = string
              text_contents = string.decode(encoding)
          else:
              raise TypeError("Expected text or bytes, got {0!r}".format(string))
  
          origin = None
          if relpath is None:
              m = hashlib.sha256()
              m.update(byte_contents)
              relpath = repr("string:{0}:{1}".format(
                  m.hexdigest()[:16], text_contents[:100]))
  
          return cls(
              origin, relpath, text_contents, encoding=encoding,
              is_sass=is_sass,
          )
docs: Read Sass source from the contents of a string.
  
          The origin is always None.  `relpath` defaults to "string:...".