Skip to content

Commit

Permalink
Add package name to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 13, 2024
1 parent 13e92a7 commit ad08f57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions komodo/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
["release_name", "maintainers", "dependencies", "versions"],
)


MISSING_PACKAGE = "missing package"
MISSING_VERSION = "missing version"
MISSING_DEPENDENCY = "missing dependency"
Expand Down Expand Up @@ -128,10 +127,12 @@ def lint(

failed_requirements = dependencies.failed_requirements()
if failed_requirements:
package_set = sorted(set(failed_requirements.values()))
deps = [
_komodo_error(
err="Failed requirements ",
err="Failed requirements:",
depends=[str(r) for r in failed_requirements],
package=", ".join(package_set),
)
]
else:
Expand Down Expand Up @@ -200,6 +201,8 @@ def lint_main():
for err in maintainers + deps + versions:
if err.err:
print(f"{err.err}")
if err.package:
print(f"{err.package}")
if err.depends:
print(" " + "\n ".join(err.depends))

Expand Down
12 changes: 8 additions & 4 deletions komodo/pypi_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
environment["python_full_version"] = python_version
environment["python_version"] = ".".join(python_version.split(".")[0:2])
self._satisfied_requirements = set()
self._failed_requirements = set()
self._failed_requirements: Dict[Requirement, str] = {}
self._used_packages = set()

self._to_install = to_install
Expand All @@ -74,7 +74,7 @@ def _update_package_sets(self, packages=None):
requirements = self._get_requirements(package_name, version)
self._used_packages.add(package_name)
for r in requirements:
_ = self.satisfied(r)
_ = self.satisfied(r, package_name)

def failed_requirements(self, packages=None):
self._update_package_sets(packages)
Expand Down Expand Up @@ -221,6 +221,7 @@ def _satisfied(
def satisfied(
self,
requirement: Requirement,
package_name: str = "",
extra=None,
) -> bool:
"""
Expand All @@ -247,9 +248,12 @@ def satisfied(
if satisfied:
self._satisfied_requirements.add(requirement)
else:
self._failed_requirements.add(requirement)
if requirement in self._failed_requirements:
self._failed_requirements[requirement] += f", {package_name}"
else:
self._failed_requirements[requirement] = package_name
return satisfied and all(
self.satisfied(transient, extra)
self.satisfied(transient, package_name, extra)
for (transients, extra) in transient_requirements
for transient in transients
)

0 comments on commit ad08f57

Please sign in to comment.