Skip to content

Commit

Permalink
fix: Fixed issue with commits from repos causing key errors, and type…
Browse files Browse the repository at this point in the history
… hint is fixed
  • Loading branch information
art1f1c3R committed Nov 27, 2024
1 parent a5dfaf1 commit 827f149
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/macaron/database/table_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PackageURLMixin:
name: Mapped[str] = mapped_column(String(100), nullable=False, comment="Name of the package.")

#: Version of the package.
version: Mapped[str] | None = mapped_column(String(100), nullable=True, comment="Version of the package.")
version: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="Version of the package.")

#: Extra qualifying data for a package such as the name of an OS.
qualifiers: Mapped[str] = mapped_column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,32 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes
"""
releases = pypi_package_json.get_releases()
if releases is None: # no release information
raise HeuristicAnalyzerValueError("There is no information for any release of this package.")
error_msg = "There is no information for any release of this package."
logger.debug(error_msg)
raise HeuristicAnalyzerValueError(error_msg)

version = pypi_package_json.component.version
if version is None: # check latest release version
version = pypi_package_json.get_latest_version()

if version is None:
raise HeuristicAnalyzerValueError("There is no latest version of this package.")
error_msg = "There is no latest version of this package."
logger.debug(error_msg)
raise HeuristicAnalyzerValueError(error_msg)

release_files: list[JsonType] = []
wheel_present: bool = False

for release_metadata in releases[version]:
if release_metadata["packagetype"] == self.WHEEL:
wheel_present = True
try:
for release_metadata in releases[version]:
if release_metadata["packagetype"] == self.WHEEL:
wheel_present = True

release_files.append(release_metadata["filename"])
release_files.append(release_metadata["filename"])
except KeyError as error:
error_msg = f"The version {version} is not available as a release."
logger.debug(error_msg)
raise HeuristicAnalyzerValueError(error_msg) from error

if wheel_present:
return HeuristicResult.PASS, {version: release_files}
Expand Down

0 comments on commit 827f149

Please sign in to comment.