Skip to content

Commit

Permalink
Remove get_dist_dependency_conflicts method as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rjduffner committed Jan 28, 2025
1 parent 149f84f commit 3533e55
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from packaging.requirements import InvalidRequirement, Requirement

from opentelemetry.util._importlib_metadata import (
Distribution,
PackageNotFoundError,
version,
)
Expand Down Expand Up @@ -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:
Expand Down
40 changes: 0 additions & 40 deletions opentelemetry-instrumentation/tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit 3533e55

Please sign in to comment.