From a4b81d17ceb2f0608e8a0816dd0caba4c4940de1 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 22 Aug 2023 21:54:15 -0500 Subject: [PATCH] refactor: remove unnecessary hashlib calls --- src/viv/viv.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/viv/viv.py b/src/viv/viv.py index d5d6463..655e955 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -52,7 +52,7 @@ from typing import ( Union, ) -__version__ = "23.8b2-13-g0136568-dev" +__version__ = "23.8b2-14-g44c8bea-dev" class Spinner: @@ -842,14 +842,11 @@ def get_hash(spec: Tuple[str, ...] | List[str], track_exe: bool = False) -> str: sha256 representation of dependencies for vivenv """ - sha256 = hashlib.sha256() - sha256.update( + return hashlib.sha256( ( str(spec) + (str(Path(sys.executable).resolve()) if track_exe else "N/A") ).encode() - ) - - return sha256.hexdigest() + ).hexdigest() class Meta: @@ -1220,8 +1217,7 @@ def fetch_source(reference: str) -> str: + "/src/viv/viv.py" ) - (hash := hashlib.sha256()).update(src.encode()) - sha256 = hash.hexdigest() + sha256 = hashlib.sha256(src.encode()).hexdigest() cached_src_file = Cfg().cache_src / f"{sha256}.py"