code: def check_valid(var, key, expected):
      r
  
      att = getattr(var, key, None)
      if att is None:
          e = 'Variable does not have a `{}` attribute.'.format(key)
          warn(e)
      elif att != expected:
          e = 'Variable has a non-conforming {}. Got `{}`, expected `{}`'.format(key, att, expected)
          warn(e)
docs: r"""Check that a variable's attribute has the expected value. Warn user otherwise.