Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Explicitly catch the InvalidGitRepositoryError when trying to get the repo information.#276

Open
sww wants to merge 1 commit intoDerwenAI:mainfrom
sww:main
Open

Explicitly catch the InvalidGitRepositoryError when trying to get the repo information.#276
sww wants to merge 1 commit intoDerwenAI:mainfrom
sww:main

Conversation

Copy link

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 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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant