refactor(utils): drop importlib.resources fallback below the 3.11 floor

requires-python is >=3.11, so the ImportError branch that guarded
importlib.resources.files is dead code. Import it at module scope and
keep only the failures files() can really raise.

The python37-compatibility rule still matches the import itself even
though 3.11 has files(). That is a false positive for this floor, so
the import carries a one-line nosemgrep.
This commit is contained in:
2026-11-06 19:29:21 +05:30
parent a79f979090
commit d5c000e58e
+2 -3
View File
@@ -32,6 +32,7 @@ import logging
import os
import re
from functools import lru_cache
from importlib.resources import files # nosemgrep: python37-compatibility-importlib2 -- py>=3.11
from typing import Dict, NamedTuple, Optional
from ..app_identity import VERIFICATION_STAMP_NAME
@@ -72,10 +73,8 @@ def _manifest_text() -> str:
:func:`verify_model_file`, which is the safe direction to fail.
"""
try:
from importlib.resources import files
return files(__package__).joinpath(_MANIFEST_NAME).read_text(encoding="utf-8")
except (ImportError, TypeError, ModuleNotFoundError):
except (TypeError, ModuleNotFoundError):
pass
except (FileNotFoundError, OSError):
return ""