Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tilelang/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def get_git_commit_id() -> Union[str, None]:
cwd=os.path.dirname(os.path.abspath(__file__)),
stderr=subprocess.DEVNULL,
encoding='utf-8').strip()
except subprocess.SubprocessError:
# FileNotFoundError is raised when git is not installed
except (subprocess.SubprocessError, FileNotFoundError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change correctly fixes the bug, it's a good practice to catch more specific exceptions. subprocess.SubprocessError is a general base class. The most likely error here, besides FileNotFoundError, is subprocess.CalledProcessError, which is raised when the command returns a non-zero exit code (e.g., if the directory is not a git repository). Using subprocess.CalledProcessError makes the error handling more precise and the code's intent clearer.

Suggested change
except (subprocess.SubprocessError, FileNotFoundError):
except (subprocess.CalledProcessError, FileNotFoundError):

return None


Expand Down