code: def generate_random_type(valid):
      
      type = choice(['int', 'str'])
  
      r = lambda: randrange(-1000000000, 1000000000)
  
      if type == 'int':
          return int,  (r() if valid else str(r()) for i in itertools.count())
      elif type == 'str':
          return str, (str(r()) if valid else r() for i in itertools.count())
      else:
          raise AssertionError('!')
docs: Generate a random type and samples for it.
  
      :param valid: Generate valid samples?
      :type valid: bool
      :return: type, sample-generator
      :rtype: type, generator