<#19507 Make it possible to refer to a group of ta...
# github-notifications
c
#19507 Make it possible to refer to a group of targets in target visibility rules Issue created by AlexTereshenkov Is your feature request related to a problem? Please describe. When declaring target visibility rules, one may find it helpful to be able to refer to a group of targets as a single entity. For instance, one may have groups of third-party dependencies in a form of
python_requirement
targets a certain target may depend on. Currently, it is necessary to do:
Copy code
__dependencies_rules__(
    (
        {"type": "*"},
        "requirements#requests",
        "requirements#tornado",
        "requirements#flask",
        "!*",
    )
)
Target visibility rules only operate on direct dependencies - they do not validate dependencies transitively. Therefore, having a
target
(or a custom target from a plugin) with
dependencies
set to
["requirements#requests", "requirements#tornado", "requirements#flask"]
won't work. Describe the solution you'd like
Copy code
# 3rdparty/BUILD
target(name="reqs-web", dependencies=["requirements#requests", "requirements#tornado", "requirements#flask"])
the rule is used to declare that targets may depend on any of these three requirements:
Copy code
__dependencies_rules__(
    (
        {"type": "*"},
        "3rdparty:reqs-web",
        "!*",
    )
)
This results in more expressive rules with less boilerplate. Describe alternatives you've considered I've experimented developing custom plugins that would have dependencies set dynamically, but the dependencies of a "composite" target are not "exploded" into individual targets, and therefore can't seem to be used in the visibility rules. Synthetic targets may provide a way to achieve this, however, this would require writing a plugin, so not ideal for a casual user. pantsbuild/pants