@@ -412,7 +412,7 @@ def _parse_and_recurse(
412412 def _parse_file (
413413 self , filename : str , constraint : bool
414414 ) -> Generator [ParsedLine , None , None ]:
415- _ , content = get_file_content (filename , self ._session )
415+ _ , content = get_file_content (filename , self ._session , constraint = constraint )
416416
417417 lines_enum = preprocess (content )
418418
@@ -572,7 +572,9 @@ def expand_env_variables(lines_enum: ReqFileLines) -> ReqFileLines:
572572 yield line_number , line
573573
574574
575- def get_file_content (url : str , session : PipSession ) -> tuple [str , str ]:
575+ def get_file_content (
576+ url : str , session : PipSession , * , constraint : bool = False
577+ ) -> tuple [str , str ]:
576578 """Gets the content of a file; it may be a filename, file: URL, or
577579 http: URL. Returns (location, content). Content is unicode.
578580 Respects # -*- coding: declarations on the retrieved files.
@@ -595,7 +597,8 @@ def get_file_content(url: str, session: PipSession) -> tuple[str, str]:
595597 with open (url , "rb" ) as f :
596598 raw_content = f .read ()
597599 except OSError as exc :
598- raise InstallationError (f"Could not open requirements file: { exc } " )
600+ kind = "constraint" if constraint else "requirements"
601+ raise InstallationError (f"Could not open { kind } file: { exc } " )
599602
600603 content = _decode_req_file (raw_content , url )
601604
0 commit comments