def _check_name_and_type()

in sourcecode/scoring/pandas_utils.py [0:0]


  def _check_name_and_type(self, name: str, dtype: Any) -> List[str]:
    """Returns a list of type mismatches if any are found, or raises an error."""
    if name not in self._expectations:
      return []
    typeExpectation = self._expectations[name]
    msg = f"Type expectation mismatch on {name}: found={dtype} expected={typeExpectation.dtype.__name__}"
    match = self._check_dtype(dtype, typeExpectation.dtype)
    if typeExpectation.logLevel == LogLevel.INFO:
      return (
        [msg]
        if not match
        else [
          f"Type expectation match on {name}: found={dtype} expected={typeExpectation.dtype.__name__}"
        ]
      )
    elif typeExpectation.logLevel == LogLevel.ERROR or not self._fail:
      return [msg] if not match else []
    else:
      assert typeExpectation.logLevel == LogLevel.FATAL
      assert self._fail
      assert match, msg
      return []