Skip to content

Commit

Permalink
_cli: remove argparse.FileType use
Browse files Browse the repository at this point in the history
This API always leaks a file handle.

Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Feb 2, 2025
1 parent 0a4145f commit ae1cb36
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pip_audit/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _parser() -> argparse.ArgumentParser: # pragma: no cover
dep_source_args.add_argument(
"-r",
"--requirement",
type=argparse.FileType("r"),
type=Path,
metavar="REQUIREMENT",
action="append",
dest="requirements",
Expand Down Expand Up @@ -465,9 +465,12 @@ def audit() -> None: # pragma: no cover

source: DependencySource
if args.requirements is not None:
req_files: list[Path] = [Path(req.name) for req in args.requirements]
for req in args.requirements:
if not req.exists():
_fatal(f"invalid requirements input: {req}")

source = RequirementSource(
req_files,
args.requirements,
require_hashes=args.require_hashes,
no_deps=args.no_deps,
disable_pip=args.disable_pip,
Expand Down

0 comments on commit ae1cb36

Please sign in to comment.