Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/get_repo_info: suppress importlib.path deprecation warning #925

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions hotsos/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import sys
import threading
import warnings
from importlib import metadata, resources
from dataclasses import dataclass, fields

Expand Down Expand Up @@ -82,15 +83,16 @@ def get_repo_info():
with open(repo_info, encoding='utf-8') as fd:
return fd.read().strip()

# pypi
# NOTE: The pylint warning is suppressed for W4902 because the
# alternative (i.e. resources.files) is not available for python
# 3.8, which is a supported environment for hotsos.
# pylint: disable-next=W4902
with resources.path('hotsos', '.repo-info') as repo_info:
if repo_info and os.path.exists(repo_info):
with open(repo_info, encoding='utf-8') as fd:
return fd.read().strip()
with warnings.catch_warnings(), contextlib.suppress(Exception):
warnings.filterwarnings("ignore", category=DeprecationWarning)
# pylint: disable-next=W4902
with resources.path('hotsos', '.repo-info') as repo_info:
if repo_info and os.path.exists(repo_info):
with open(repo_info, encoding='utf-8') as fd:
return fd.read().strip()

try:
out = subprocess.check_output(['git', '-C', get_hotsos_root(),
Expand Down
Loading