Skip to content

Commit

Permalink
packages.LocalPackageLookup: Remove redundant sanity check
Browse files Browse the repository at this point in the history
When we added the venv_path argument to LocalPackageLookup, we retained
a sanity check for the default venv_path=None case, where we compared
the new method of building .packages against the old method method
(using packages_distributions()), and aborted if these were not 100%
equivalent.

After adding a test to test_real_projects, we have now verified that
this sanity check holds for all of the venvs we use as part of our
real_projects test. Since the sanity check has not triggered, we can
conclude that these methods are in fact equivalent, and we can drop
this sanity check.
  • Loading branch information
jherland committed Mar 14, 2023
1 parent 3f92de2 commit e75553d
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions fawltydeps/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
MetadataPathFinder,
_top_level_declared,
_top_level_inferred,
packages_distributions,
)

from fawltydeps.utils import hide_dataclass_fields
Expand Down Expand Up @@ -154,28 +153,6 @@ def packages(self) -> Dict[str, Package]:
package = Package(dist.name, {DependenciesMapping.LOCAL_ENV: imports})
self._packages[Package.normalize_name(dist.name)] = package

# Double-check against packages_distributions()
if self.venv_path is None:
verify: Dict[str, Package] = {}
for import_name, package_names in packages_distributions().items():
for package_name in package_names:
package = verify.setdefault(
Package.normalize_name(package_name),
Package(package_name),
)
package.add_import_names(
import_name, mapping=DependenciesMapping.LOCAL_ENV
)

# Note that packages_distributions() is not able to return packages
# that map to zero import names.
for name, package in self._packages.items():
if name not in verify:
assert not package.import_names # No import names!
verify[name] = package

assert self._packages == verify

return self._packages

def lookup_package(self, package_name: str) -> Optional[Package]:
Expand Down

0 comments on commit e75553d

Please sign in to comment.