From 0891aa5a7bd340e8f0dab3de23b9f8cf6e70e799 Mon Sep 17 00:00:00 2001 From: shouzy <82171453+realshouzy@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:25:26 +0100 Subject: [PATCH] Make optimizations --- pip_review.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pip_review.py b/pip_review.py index a7bdc13f..308426c8 100755 --- a/pip_review.py +++ b/pip_review.py @@ -283,7 +283,7 @@ def update_packages( def _get_outdated_packages( forwarded: list[str], - exclude: list[str], + exclude: set[str], ) -> list[dict[str, str]]: command: list[str] = [ *PIP_CMD, @@ -295,7 +295,9 @@ def _get_outdated_packages( ] output: str = subprocess.check_output(command).decode("utf-8") # nosec packages: list[dict[str, str]] = json.loads(output) - return [pkg for pkg in packages if pkg["name"] not in exclude] + return ( + [pkg for pkg in packages if pkg["name"] not in exclude] if exclude else packages + ) # Next two functions describe how to collect data for the table. @@ -338,7 +340,10 @@ def main() -> int: # noqa: C901 logger.error("--raw and --interactive cannot be used together") return 1 - outdated: list[dict[str, str]] = _get_outdated_packages(list_args, args.exclude) + outdated: list[dict[str, str]] = _get_outdated_packages( + list_args, + set(args.exclude), + ) if not outdated and not args.raw: logger.info("Everything up-to-date")