Skip to content

Commit

Permalink
Only create TOMLFile instance if required
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored Aug 18, 2024
1 parent 9b970cb commit c7743c1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ def _should_write(self, lock: TOMLDocument) -> bool:
return do_write

def _write_lock_data(self, data: TOMLDocument) -> None:
lockfile = TOMLFile(self.lock)

if self.lock.exists():
# The following code is roughly equivalent to
# • lockfile = TOMLFile(self.lock)
Expand All @@ -317,6 +315,7 @@ def _write_lock_data(self, data: TOMLDocument) -> None:
f.write(content)

else:
lockfile = TOMLFile(self.lock)
lockfile.write(data)

self._lock_data = None
Expand Down

0 comments on commit c7743c1

Please sign in to comment.