From d70bac1133000af71eb0cad0117e419b082a1362 Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Thu, 28 May 2020 23:25:19 -0700 Subject: [PATCH] Deprecate plugin targets not having Target API bindings (#9896) Refer to https://groups.google.com/forum/#!topic/pants-devel/WsRFODRLVZI. We put the deprecation in the `transitive_hydrated_targets` rule because this gets executed every single V1 run and shouldn't be executed more than once in V1 code paths. [ci skip-rust-tests] [ci skip-jvm-tests] --- src/python/pants/engine/legacy/graph.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/python/pants/engine/legacy/graph.py b/src/python/pants/engine/legacy/graph.py index 646e0790d11..4ab015e4cc9 100644 --- a/src/python/pants/engine/legacy/graph.py +++ b/src/python/pants/engine/legacy/graph.py @@ -8,6 +8,7 @@ from dataclasses import dataclass from typing import Any, Dict, Iterable, Iterator, List, Set, Tuple, Type, cast +from pants.base.deprecated import deprecated_conditional from pants.base.exceptions import TargetDefinitionException from pants.base.parse_context import ParseContext from pants.base.specs import AddressSpec, AddressSpecs, SingleAddress @@ -31,6 +32,7 @@ ) from pants.engine.rules import rule from pants.engine.selectors import Get, MultiGet +from pants.engine.target import RegisteredTargetTypes from pants.option.global_options import GlobMatchErrorBehavior from pants.source.wrapped_globs import EagerFilesetWithSpec, FilesetRelPathWrapper, Filespec from pants.util.meta import frozen_after_init @@ -422,7 +424,9 @@ class LegacyTransitiveHydratedTargets: @rule -async def transitive_hydrated_targets(addresses: Addresses) -> TransitiveHydratedTargets: +async def transitive_hydrated_targets( + addresses: Addresses, registered_target_types: RegisteredTargetTypes +) -> TransitiveHydratedTargets: """Given Addresses, kicks off recursion on expansion of TransitiveHydratedTargets. The TransitiveHydratedTarget struct represents a structure-shared graph, which we walk and @@ -445,6 +449,25 @@ async def transitive_hydrated_targets(addresses: Addresses) -> TransitiveHydrate closure.add(tht.root) to_visit.extend(tht.dependencies) + no_target_api_bindings = { + ht.adaptor.type_alias + for ht in closure + if ht.adaptor.type_alias not in registered_target_types.aliases + } + deprecated_conditional( + predicate=lambda: bool(no_target_api_bindings), + removal_version="1.30.0.dev0", + entity_description="Custom V1 targets not having a Target API binding", + hint_message=( + "You have some custom target types that will soon need light-weight bindings for the " + "new and more powerful Target API to continue working properly with parts of Pants, " + "like the `list` and `filedeps` goals.\n\nSee " + "https://groups.google.com/forum/#!topic/pants-devel/WsRFODRLVZI for more information " + f"and instructions.\n\n(Could not find bindings for: {sorted(no_target_api_bindings)})" + ), + stacklevel=4, + ) + return TransitiveHydratedTargets( tuple(tht.root for tht in transitive_hydrated_targets), FrozenOrderedSet(closure) )