code: def parse_requirements(
      filename,  # type: str
      finder=None,  # type: Optional[PackageFinder]
      comes_from=None,  # type: Optional[str]
      options=None,  # type: Optional[optparse.Values]
      session=None,  # type: Optional[PipSession]
      constraint=False,  # type: bool
      wheel_cache=None,  # type: Optional[WheelCache]
      use_pep517=None  # type: Optional[bool]
  ):
      # type: (...) -> Iterator[InstallRequirement]
      
      if session is None:
          raise TypeError(
              "parse_requirements() missing 1 required keyword argument: "
              "'session'"
          )
  
      _, content = get_file_content(
          filename, comes_from=comes_from, session=session
      )
  
      lines_enum = preprocess(content, options)
  
      for line_number, line in lines_enum:
          req_iter = process_line(line, filename, line_number, finder,
                                  comes_from, options, session, wheel_cache,
                                  use_pep517=use_pep517, constraint=constraint)
          for req in req_iter:
              yield req
docs: Parse a requirements file and yield InstallRequirement instances.
  
      :param filename:    Path or url of requirements file.
      :param finder:      Instance of pip.index.PackageFinder.
      :param comes_from:  Origin description of requirements.
      :param options:     cli options.
      :param session:     Instance of pip.download.PipSession.
      :param constraint:  If true, parsing a constraint file rather than
          requirements file.
      :param wheel_cache: Instance of pip.wheel.WheelCache
      :param use_pep517:  Value of the --use-pep517 option.