code: def write(self, file_des, contents):
          
          file_handle = self.filesystem.get_open_file(file_des)
          if isinstance(file_handle, FakeDirWrapper):
              self.filesystem.raise_os_error(errno.EBADF, file_handle.file_path)
  
          if isinstance(file_handle, FakePipeWrapper):
              return file_handle.write(contents)
  
          file_handle.raw_io = True
          file_handle._sync_io()
          file_handle.update_flush_pos()
          file_handle.write(contents)
          file_handle.flush()
          return len(contents)
docs: Write string to file descriptor, returns number of bytes written.
  
          Args:
              file_des: An integer file descriptor for the file object requested.
              contents: String of bytes to write to file.
  
          Returns:
              Number of bytes written.
  
          Raises:
              OSError: bad file descriptor.
              TypeError: if file descriptor is not an integer.