From 796b52849b179cf341319b8cdefa43650de6c296 Mon Sep 17 00:00:00 2001 From: Christopher Bailey Date: Sat, 1 Jul 2023 11:37:36 -0400 Subject: [PATCH] Fixes unclosed file --- guarddog/analyzer/metadata/pypi/typosquatting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guarddog/analyzer/metadata/pypi/typosquatting.py b/guarddog/analyzer/metadata/pypi/typosquatting.py index 308535cf..84be4436 100644 --- a/guarddog/analyzer/metadata/pypi/typosquatting.py +++ b/guarddog/analyzer/metadata/pypi/typosquatting.py @@ -57,8 +57,8 @@ def _get_top_packages(self) -> list: update_time = datetime.fromtimestamp(os.path.getmtime(top_packages_path)) if datetime.now() - update_time <= timedelta(days=30): - top_packages_file = open(top_packages_path, "r") - top_packages_information = json.load(top_packages_file)["rows"] + with open(top_packages_path, "r") as top_packages_file: + top_packages_information = json.load(top_packages_file)["rows"] if top_packages_information is None: response = requests.get(popular_packages_url).json()