Use context manager when opening Pipfile

This commit is contained in:
Oz N Tiram
2022-09-14 00:55:16 +02:00
parent 1b8f6278df
commit b44dfd1e0a
2 changed files with 2 additions and 4 deletions
-1
View File
@@ -1028,7 +1028,6 @@ def do_lock(
pypi_mirror=None,
):
"""Executes the freeze functionality."""
cached_lockfile = {}
if not pre:
pre = project.settings.get("allow_prereleases")
+2 -3
View File
@@ -556,9 +556,8 @@ class Project:
@property
def _lockfile(self):
"""Pipfile.lock divided by PyPI and external dependencies."""
lockfile = plette.Lockfile.with_meta_from(
plette.Pipfile.load(open(self.pipfile_location))
)
with open(self.pipfile_location) as pf:
lockfile = plette.Lockfile.with_meta_from(plette.Pipfile.load(pf))
for section in ("default", "develop"):
lock_section = lockfile.get(section, {})
for key in list(lock_section.keys()):