pytextrank
pytextrank copied to clipboard
Explicitly catch the InvalidGitRepositoryError when trying to get the repo information.
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 https://github.com/DerwenAI/pytextrank/blob/5a92184d0b8c4954fcda0a85690e57bf752dd407/pytextrank/version.py#L21-L28 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.