Skip to content

Commit 861ce58

Browse files
committed
chore: lint fix
Signed-off-by: habeck <habeck@us.ibm.com>
1 parent d31d30f commit 861ce58

4 files changed

Lines changed: 24 additions & 36 deletions

File tree

cpex/tools/catalog.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,9 @@ def install_folder_via_pip(self, manifest: PluginManifest, verify_integrity: boo
642642
if manifest.kind == "isolated_venv":
643643
logger.info("Detected isolated_venv plugin from monorepo: %s", manifest.name)
644644
# Install the package to make it available for venv initialization
645-
package_path = self._download_monorepo_folder_to_temp(repo_url, manifest.name, verify_integrity=verify_integrity)
645+
package_path = self._download_monorepo_folder_to_temp(
646+
repo_url, manifest.name, verify_integrity=verify_integrity
647+
)
646648
plugin_path = self._initialize_isolated_venv(manifest, package_path)
647649
logger.info("Isolated venv initialized. Plugin will be auto-installed via requirements.txt")
648650
else:
@@ -835,7 +837,9 @@ def _extract_package_archive(self, package_file: Path, extract_dir: Path) -> Non
835837
else:
836838
raise RuntimeError(f"Unsupported package format: {package_file}")
837839

838-
def _download_monorepo_folder_to_temp(self, repo_url: str, package_name: str, verify_integrity: bool = True) -> Path:
840+
def _download_monorepo_folder_to_temp(
841+
self, repo_url: str, package_name: str, verify_integrity: bool = True
842+
) -> Path:
839843
"""Download monorepo folder to temporary directory.
840844
841845
Args:
@@ -873,16 +877,12 @@ def _download_monorepo_folder_to_temp(self, repo_url: str, package_name: str, ve
873877
if verify_integrity:
874878
try:
875879
from cpex.tools.integrity import compute_file_hash
880+
876881
package_hash = compute_file_hash(package_file)
877882
logger.info(
878-
"Package integrity hash for %s (%s): SHA256=%s",
879-
package_name,
880-
package_file.name,
881-
package_hash
882-
)
883-
logger.info(
884-
"Store this hash for future verification or to detect tampering"
883+
"Package integrity hash for %s (%s): SHA256=%s", package_name, package_file.name, package_hash
885884
)
885+
logger.info("Store this hash for future verification or to detect tampering")
886886
except Exception as e:
887887
logger.warning("Failed to compute package hash: %s", str(e))
888888

@@ -940,14 +940,13 @@ def _download_package_to_temp(
940940
if version_constraint:
941941
# Try to extract exact version from constraint (e.g., "==1.0.0" -> "1.0.0")
942942
import re
943-
version_match = re.search(r'==\s*([0-9.]+)', version_constraint)
943+
944+
version_match = re.search(r"==\s*([0-9.]+)", version_constraint)
944945
if version_match:
945946
version_to_fetch = version_match.group(1)
946-
947+
947948
expected_hashes = fetch_pypi_package_hashes(
948-
package_name=package_name,
949-
version=version_to_fetch,
950-
use_test=use_test
949+
package_name=package_name, version=version_to_fetch, use_test=use_test
951950
)
952951
if expected_hashes:
953952
logger.info("Retrieved hashes for %d distribution files", len(expected_hashes))
@@ -988,16 +987,10 @@ def _download_package_to_temp(
988987
if expected_hash:
989988
logger.info("Verifying integrity of %s", package_file.name)
990989
verify_package_integrity(
991-
file_path=package_file,
992-
expected_hash=expected_hash,
993-
package_name=package_name,
994-
strict=True
990+
file_path=package_file, expected_hash=expected_hash, package_name=package_name, strict=True
995991
)
996992
else:
997-
logger.warning(
998-
"No matching hash found for %s. Proceeding without verification.",
999-
package_file.name
1000-
)
993+
logger.warning("No matching hash found for %s. Proceeding without verification.", package_file.name)
1001994

1002995
extract_dir = temp_dir / "extracted"
1003996
extract_dir.mkdir()
@@ -1509,16 +1502,12 @@ def install_from_git(self, url: str, verify_integrity: bool = True) -> tuple[Plu
15091502
if verify_integrity:
15101503
try:
15111504
from cpex.tools.integrity import compute_file_hash
1505+
15121506
package_hash = compute_file_hash(archive_path)
15131507
logger.info(
1514-
"Package integrity hash for %s (%s): SHA256=%s",
1515-
package_name,
1516-
archive_path.name,
1517-
package_hash
1518-
)
1519-
logger.info(
1520-
"Store this hash for future verification or to detect tampering"
1508+
"Package integrity hash for %s (%s): SHA256=%s", package_name, archive_path.name, package_hash
15211509
)
1510+
logger.info("Store this hash for future verification or to detect tampering")
15221511
except Exception as e:
15231512
logger.warning("Failed to compute package hash: %s", str(e))
15241513

cpex/tools/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
)
4848
from cpex.framework.settings import settings
4949
from cpex.tools.catalog import PluginCatalog
50-
from cpex.tools.settings import get_catalog_settings
5150

5251
# Third-Party
5352
from cpex.tools.plugin_registry import PluginRegistry
53+
from cpex.tools.settings import get_catalog_settings
5454

5555
# Exit codes for CLI commands
5656
EXIT_SUCCESS = 0
@@ -584,9 +584,9 @@ def _install_from_pypi(source: str, catalog: PluginCatalog, use_test: bool = Fal
584584
verify_integrity = catalog_settings.VERIFY_PACKAGE_INTEGRITY
585585

586586
if verify_integrity:
587-
console.log(f"Package integrity verification: enabled")
587+
console.log("Package integrity verification: enabled")
588588
else:
589-
console.log(f"Package integrity verification: disabled")
589+
console.log("Package integrity verification: disabled")
590590

591591
with console.status(f"Installing plugin {package_name} via pypi", spinner="dots"):
592592
manifest, plugin_path = catalog.install_from_pypi(

cpex/tools/integrity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,5 @@ def find_matching_hash(
297297
logger.warning("No matching hash found for %s in PyPI metadata", pkg_name)
298298
return None
299299

300+
300301
# Made with Bob

cpex/tools/settings.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ class CatalogSettings(BaseSettings):
4040
)
4141
FOLDER: str = Field(default="plugins", description="The folder where the plugins are located (r/w)")
4242
VERIFY_PACKAGE_INTEGRITY: bool = Field(
43-
default=True,
44-
description="Enable SHA256 hash verification for downloaded packages from PyPI"
43+
default=True, description="Enable SHA256 hash verification for downloaded packages from PyPI"
4544
)
4645
STRICT_INTEGRITY_MODE: bool = Field(
47-
default=False,
48-
description="Fail installation if package hashes are unavailable (strict mode)"
46+
default=False, description="Fail installation if package hashes are unavailable (strict mode)"
4947
)
5048

5149

0 commit comments

Comments
 (0)