docs: def check_refresh(self, data, ret):
          '''
          Check to see if the modules for this state instance need to be updated,
          only update if the state is a file or a package and if it changed
          something. If the file function is managed check to see if the file is a
          possible module type, e.g. a python, pyx, or .so. Always refresh if the
          function is recurse, since that can lay down anything.
          '''
          _reload_modules = False
          if data.get('reload_grains', False):
              log.debug('Refreshing grains...')
              self.opts['grains'] = salt.loader.grains(self.opts)
              _reload_modules = True
  
          if data.get('reload_pillar', False):
              log.debug('Refreshing pillar...')
              self.opts['pillar'] = self._gather_pillar()
              _reload_modules = True
  
          if not ret['changes']:
              if data.get('force_reload_modules', False):
                  self.module_refresh()
              return
  
          if data.get('reload_modules', False) or _reload_modules:
              # User explicitly requests a reload
              self.module_refresh()
              return
  
          if data['state'] == 'file':
              if data['fun'] == 'managed':
                  if data['name'].endswith(
                      ('.py', '.pyx', '.pyo', '.pyc', '.so')):
                      self.module_refresh()
              elif data['fun'] == 'recurse':
                  self.module_refresh()
              elif data['fun'] == 'symlink':
                  if 'bin' in data['name']:
                      self.module_refresh()
          elif data['state'] in ('pkg', 'ports'):
              self.module_refresh()