diff --git a/conans/model/dependencies.py b/conans/model/dependencies.py index 56db54aadb6..c6f1af8f72d 100644 --- a/conans/model/dependencies.py +++ b/conans/model/dependencies.py @@ -26,6 +26,9 @@ def __bool__(self): return bool(self._data) def get(self, ref, build=None, **kwargs): + return self._get(ref, build, **kwargs)[1] + + def _get(self, ref, build=None, **kwargs): if build is None: current_filters = self._require_filter or {} if "build" not in current_filters: @@ -54,14 +57,14 @@ def get(self, ref, build=None, **kwargs): if not ret: raise KeyError("'{}' not found in the dependency set".format(ref)) - _, value = ret[0] - return value + key, value = ret[0] + return key, value def __getitem__(self, name): return self.get(name) def __delitem__(self, name): - r = self.get(name) + r, _ = self._get(name) del self._data[r] def items(self): diff --git a/conans/test/integration/package_id/build_id_test.py b/conans/test/integration/package_id/build_id_test.py index 5a5b226192b..4540c734af1 100644 --- a/conans/test/integration/package_id/build_id_test.py +++ b/conans/test/integration/package_id/build_id_test.py @@ -7,6 +7,7 @@ from conans.model.package_ref import PkgReference from conans.model.recipe_ref import RecipeReference +from conans.test.assets.genconanfile import GenConanfile from conans.test.utils.tools import TestClient from conans.util.files import load @@ -275,3 +276,20 @@ def build(self): self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5", client.out) client.run("create . --name=pkg --version=0.1 --user=user --channel=channel", assert_error=True) self.assertIn("ERROR: pkg/0.1@user/channel: Error in build() method, line 5", client.out) + + +def test_remove_require(): + c = TestClient() + remove = textwrap.dedent(""" + from conan import ConanFile + class Pkg(ConanFile): + name = "consumer" + version = "1.0" + requires = "dep/1.0" + def build_id(self): + self.info_build.requires.remove("dep") + """) + c.save({"dep/conanfile.py": GenConanfile("dep", "1.0"), + "consumer/conanfile.py": remove}) + c.run("create dep") + c.run("create consumer")