diff --git a/src/pip/_internal/utils/outdated.py b/src/pip/_internal/utils/outdated.py index e1f9129d1..2525a7955 100644 --- a/src/pip/_internal/utils/outdated.py +++ b/src/pip/_internal/utils/outdated.py @@ -78,15 +78,13 @@ class SelfCheckState(object): # Attempt to write out our version check file with lockfile.LockFile(self.statefile_path): - if os.path.exists(self.statefile_path): - with open(self.statefile_path) as statefile: - state = json.load(statefile) - else: - state = {} - - state[self.key] = { - "last_check": current_time.strftime(SELFCHECK_DATE_FMT), - "pypi_version": pypi_version, + # Since we have a prefix-specific state file, we can just + # overwrite whatever is there, no need to check. + state = { + self.key: { + "last_check": current_time.strftime(SELFCHECK_DATE_FMT), + "pypi_version": pypi_version, + }, } with open(self.statefile_path, "w") as statefile: diff --git a/tests/unit/test_unit_outdated.py b/tests/unit/test_unit_outdated.py index 6a7c6a0e0..04c641408 100644 --- a/tests/unit/test_unit_outdated.py +++ b/tests/unit/test_unit_outdated.py @@ -197,7 +197,6 @@ def test_self_check_state(monkeypatch, tmpdir): assert fake_lock.calls == [pretend.call(expected_path)] assert fake_open.calls == [ - pretend.call(expected_path), pretend.call(expected_path), pretend.call(expected_path, 'w'), ]