class_docstr: This a wrapper object for a user-defined function that is called
  at deploy time to populate fields in a Parameter. The wrapper
  is needed to make Click show the actual value returned by the
  function instead of a function pointer in its help text. Also, this
  object curries the context argument for the function, and pretty
  prints any exceptions that occur during evaluation.
class_docstr_tok: ["This","a","wrapper","object","for","a","user-defined","function","that","is","called","at","deploy","time","to","populate","fields","in","a","Parameter",".","The","wrapper","is","needed","to","make","Click","show","the","actual","value","returned","by","the","function","instead","of","a","function","pointer","in","its","help","text",".","Also",",","this","object","curries","the","context","argument","for","the","function",",","and","pretty","prints","any","exceptions","that","occur","during","evaluation","."]
code: def _check_type(self, val, deploy_time):
      # it is easy to introduce a deploy-time function that accidentally
      # returns a value whose type is not compatible with what is defined
      # in Parameter. Let's catch those mistakes early here, instead of
      # showing a cryptic stack trace later.
  
      # note: this doesn't work with long in Python2 or types defined as
      # click types, e.g. click.INT
      TYPES = {bool: "bool", int: "int", float: "float", list: "list"}
  
      msg = (
          "The value returned by the deploy-time function for "
          "the parameter *%s* field *%s* has a wrong type. "
          % (self.parameter_name, self.field)
      )
  
      if self.parameter_type in TYPES:
          if type(val) != self.parameter_type:
              msg += "Expected a %s." % TYPES[self.parameter_type]
              raise ParameterFieldTypeMismatch(msg)
          return str(val) if self.return_str else val
      else:
          if deploy_time:
              try:
                  if not is_stringish(val):
                      val = json.dumps(val)
              except TypeError:
                  msg += "Expected a JSON-encodable object or a string."
                  raise ParameterFieldTypeMismatch(msg)
              return val
          # If not deploy_time, we expect a string
          if not is_stringish(val):
              msg += "Expected a string."
              raise ParameterFieldTypeMismatch(msg)
          return val
  
imports: import json
  from typing import Any, Callable, Dict, NamedTuple, Optional, Type, Union
  from metaflow._vendor import click
  from .util import get_username, is_stringish
  from .exception import ParameterFieldFailed, ParameterFieldTypeMismatch, MetaflowException
label_desc: Use image node_id 3 for calling the DeployTimeField obj's underlying member method code with example usage: obj._check_type(val, deploy_time) and returns: unknown, val, val