code: def set_filetype(self, filetype, bufnr=None):
          
          if bufnr:
              self._vim.command(str(bufnr) + 'bufdo set filetype=' + filetype)
          else:
              self._vim.command('set filetype=' + filetype)
docs: Set filetype for a buffer.
  
          Note: it's a quirk of Vim's Python API that using the buffer.options
          dictionary to set filetype does not trigger ``FileType`` autocommands,
          hence this implementation executes as a command instead.
  
          Args:
              filetype (str): The filetype to set.
              bufnr (Optional[int]): A Vim buffer number, current if ``None``.