From b5fc5adb2299d65c3401f345b25a195eea7a6037 Mon Sep 17 00:00:00 2001 From: Sean Wang Date: Mon, 3 Jun 2024 16:01:35 -0700 Subject: [PATCH] Explicitly catch the InvalidGitRepositoryError when trying to the repo information. Before, when importing pytextrank installed via pip, it would print the path to the library. --- pytextrank/version.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytextrank/version.py b/pytextrank/version.py index 8e8f46d..4cf02b0 100644 --- a/pytextrank/version.py +++ b/pytextrank/version.py @@ -12,6 +12,7 @@ import typing from git import Repo # pylint: disable=E0401 # type: ignore +from git.exc import InvalidGitRepositoryError ## use the local Git info for version info, if available @@ -24,9 +25,8 @@ REPO_HASH = str(repo.head.commit) REPO_TAGS = repo.tags -except Exception as ex: # pylint: disable=W0703 - print(ex) - +except InvalidGitRepositoryError: + pass # cast version string into a float try: