Skip to content

Conversation

@sww
Copy link

@sww sww commented Jun 3, 2024

If pytextrank is installed via pip, importing pytextrank prints out the root directory where it's installed.

Steps To Reproduce

With Docker using the python:3.12 image, run:

$ pip install pytextrank
$ python -c "import pytextrank"
/usr/local/lib/python3.12/site-packages
$ pip freeze | grep pytextrank
pytextrank==3.3.0

Discussion

The code

try:
repo_path: pathlib.Path = pathlib.Path(dirname(abspath(__file__)))
repo: Repo = Repo(repo_path.parents[0])
REPO_HASH = str(repo.head.commit)
REPO_TAGS = repo.tags
except Exception as ex: # pylint: disable=W0703
print(ex)
is trying to load git information from the installed location, but since there isn't a git repo there, it just prints the InvalidGitRepositoryError exception arguments, which is just a path.

By explicitly catching that exception, it should no longer print out some unnecessary information. This PR will still raise an other unexpected exceptions, though.

…o information.

Before, when importing pytextrank installed via pip, it would print the path
to the library.
@sww sww changed the title Explicitly catch the InvalidGitRepositoryError when trying to the repo information. Explicitly catch the InvalidGitRepositoryError when trying to get the repo information. Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant