git.py: module-level import-time side effect with shutil.which #125

Closed
opened 2026-07-06 04:50:43 +00:00 by the.auditor · 0 comments
Owner

src/hottea/git.py:11-14 runs shutil.which("git") at module level. If git is not on PATH, it raises GitNotFoundError at import time.

This breaks:

  • Importing the module for introspection in environments without git
  • Test discovery if tests are collected in a git-less environment
  • Any usage of the module that wants to handle the "no git" case gracefully

Recommendation: Move the check into a lazy initializer or into _run_git() so the module can be imported safely. The GitNotFoundError can still be raised at call time.

Ref: PR #124

`src/hottea/git.py:11-14` runs `shutil.which("git")` at module level. If git is not on PATH, it raises `GitNotFoundError` at import time. This breaks: - Importing the module for introspection in environments without git - Test discovery if tests are collected in a git-less environment - Any usage of the module that wants to handle the "no git" case gracefully Recommendation: Move the check into a lazy initializer or into `_run_git()` so the module can be imported safely. The `GitNotFoundError` can still be raised at call time. Ref: PR #124
fuzzy closed this issue 2026-07-06 08:20:04 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/hottea#125
No description provided.