parameters: (start, end, step=relativedelta(months=1))
docstring: Date range generator with a step interval.
  
      :param start datetime: beginning date of the range.
      :param end datetime: ending date of the range.
      :param step relativedelta: interval of the range.
      :return: a range of datetime from start to end.
      :rtype: Iterator[datetime]
docstring_summary: Date range generator with a step interval.
docstring_tokens: Date range generator with a step interval .
function: def date_range(start, end, step=relativedelta(months=1)):
      """Date range generator with a step interval.
  
      :param start datetime: beginning date of the range.
      :param end datetime: ending date of the range.
      :param step relativedelta: interval of the range.
      :return: a range of datetime from start to end.
      :rtype: Iterator[datetime]
      """
  
      are_naive = start.tzinfo is None and end.tzinfo is None
      are_utc = start.tzinfo == pytz.utc and end.tzinfo == pytz.utc
  
      # Cases with miscellenous timezone are more complexe because of DST.
      are_others = start.tzinfo and end.tzinfo and not are_utc
  
      if are_others:
          if start.tzinfo.zone != end.tzinfo.zone:
              raise ValueError("Timezones of start argument and end argument seem inconsistent")
  
      if not are_naive and not are_utc and not are_others:
          raise ValueError("Timezones of start argument and end argument mismatch")
  
      if start > end:
          raise ValueError("start > end, start date must be before end")
  
      if start == start + step:
          raise ValueError("Looks like step is null")
  
      if start.tzinfo:
          localize = start.tzinfo.localize
      else:
          localize = lambda dt: dt
  
      dt = start.replace(tzinfo=None)
      end = end.replace(tzinfo=None)
      while dt <= end:
          yield localize(dt)
          dt = dt + step
function_tokens: def date_range ( start , end , step = relativedelta ( months = 1 ) ) : are_naive = start . tzinfo is None and end . tzinfo is None are_utc = start . tzinfo == pytz . utc and end . tzinfo == pytz . utc # Cases with miscellenous timezone are more complexe because of DST. are_others = start . tzinfo and end . tzinfo and not are_utc if are_others : if start . tzinfo . zone != end . tzinfo . zone : raise ValueError ( "Timezones of start argument and end argument seem inconsistent" ) if not are_naive and not are_utc and not are_others : raise ValueError ( "Timezones of start argument and end argument mismatch" ) if start > end : raise ValueError ( "start > end, start date must be before end" ) if start == start + step : raise ValueError ( "Looks like step is null" ) if start . tzinfo : localize = start . tzinfo . localize else : localize = lambda dt : dt dt = start . replace ( tzinfo = None ) end = end . replace ( tzinfo = None ) while dt <= end : yield localize ( dt ) dt = dt + step