From aad16796212eed72c477b0133a8e1f945636becc Mon Sep 17 00:00:00 2001 From: rjduffner Date: Tue, 28 Jan 2025 13:52:11 -0800 Subject: [PATCH] Remove get_dist_dependency_conflicts method as well --- .../instrumentation/dependencies.py | 20 ---------- .../tests/test_dependencies.py | 40 ------------------- 2 files changed, 60 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 57a78c23c5..e9bb35094f 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -20,7 +20,6 @@ from packaging.requirements import InvalidRequirement, Requirement from opentelemetry.util._importlib_metadata import ( - Distribution, PackageNotFoundError, version, ) @@ -48,25 +47,6 @@ def __str__(self): return str(self.conflict) -def get_dist_dependency_conflicts( - dist: Distribution, -) -> DependencyConflict | None: - instrumentation_deps = [] - extra = "extra" - instruments = "instruments" - instruments_marker = {extra: instruments} - if dist.requires: - for dep in dist.requires: - if extra not in dep or instruments not in dep: - continue - - req = Requirement(dep) - if req.marker.evaluate(instruments_marker): - instrumentation_deps.append(req) - - return get_dependency_conflicts(instrumentation_deps) - - def get_dependency_conflicts( deps: Collection[str | Requirement], ) -> DependencyConflict | None: diff --git a/opentelemetry-instrumentation/tests/test_dependencies.py b/opentelemetry-instrumentation/tests/test_dependencies.py index ca04833181..a06d3923ea 100644 --- a/opentelemetry-instrumentation/tests/test_dependencies.py +++ b/opentelemetry-instrumentation/tests/test_dependencies.py @@ -20,10 +20,8 @@ from opentelemetry.instrumentation.dependencies import ( DependencyConflict, get_dependency_conflicts, - get_dist_dependency_conflicts, ) from opentelemetry.test.test_base import TestBase -from opentelemetry.util._importlib_metadata import Distribution class TestDependencyConflicts(TestBase): @@ -64,41 +62,3 @@ def test_get_dependency_conflicts_mismatched_version(self): str(conflict), f'DependencyConflict: requested: "pytest == 5000" but found: "pytest {pytest.__version__}"', ) - - def test_get_dist_dependency_conflicts(self): - class MockDistribution(Distribution): - def locate_file(self, path): - pass - - def read_text(self, filename): - pass - - @property - def requires(self): - return ['test-pkg ~= 1.0; extra == "instruments"'] - - dist = MockDistribution() - - conflict = get_dist_dependency_conflicts(dist) - self.assertTrue(conflict is not None) - self.assertTrue(isinstance(conflict, DependencyConflict)) - self.assertEqual( - str(conflict), - 'DependencyConflict: requested: "test-pkg~=1.0; extra == "instruments"" but found: "None"', - ) - - def test_get_dist_dependency_conflicts_requires_none(self): - class MockDistribution(Distribution): - def locate_file(self, path): - pass - - def read_text(self, filename): - pass - - @property - def requires(self): - return None - - dist = MockDistribution() - conflict = get_dist_dependency_conflicts(dist) - self.assertTrue(conflict is None)