internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pantsbuild/pants

Issue:
`help` output does not mention `symbols`
**Describe the bug**
`./pants help symbols` was added in #18378. But `./pants help` and `./pants help-advanced` do not mention it.

Also, `./pants help [name]` should also mention `symbols` as a valid type of name.

**Pants version**
2.16.0a0

**OS**
both


Discussion:

Resolving patch:
diff --git a/src/python/pants/help/help_printer.py b/src/python/pants/help/help_printer.py
--- a/src/python/pants/help/help_printer.py
+++ b/src/python/pants/help/help_printer.py
@@ -427,6 +427,11 @@ def print_cmd(args: str, desc: str):
         print_cmd("help tools", "List all external tools.")
         print_cmd("help backends", "List all available backends.")
         print_cmd("help-advanced backends", "List all backends, including experimental/preview.")
+        print_cmd("help symbols", "List available BUILD file symbols.")
+        print_cmd(
+            "help-advanced symbols",
+            "List all available BUILD file symbols, including target types.",
+        )
         print_cmd("help api-types", "List all plugin API types.")
         print_cmd("help global", "Help for global options.")
         print_cmd("help-advanced global", "Help for global advanced options.")


Test patch:
Repository: pantsbuild/pants

Issue:
`help backends` and `help-advanced backends` show the same content (both include preview/experimental backends)
**Describe the bug**
Under the `help` goal: `help backends` and `help-advanced backends` show the same content (both include preview/experimental backends). Only the `-advanced` variant should show the preview/experimental backends (according to the `help` output).

```
Usage:
  ...
  ./pants help backends                      List all available backends.
  ./pants help-advanced backends             List all backends, including experimental/preview.
  ...
```

Either remove the experimental/preview backends from the `help backends` view, or just remove the `help-advanced` version.

**Pants version**
2.16.0a0

**OS**
Both


Discussion:

Resolving patch:
diff --git a/src/python/pants/help/help_printer.py b/src/python/pants/help/help_printer.py
--- a/src/python/pants/help/help_printer.py
+++ b/src/python/pants/help/help_printer.py
@@ -227,7 +227,7 @@ def _print_top_level_help(self, thing: str, show_advanced: bool) -> None:
         elif thing == "api-types":
             self._print_all_api_types()
         elif thing == "backends":
-            self._print_all_backends()
+            self._print_all_backends(show_advanced)
         elif thing == "symbols":
             self._print_all_symbols(show_advanced)
 
@@ -343,7 +343,7 @@ def _print_all_api_types(self) -> None:
             f"Use `{self.maybe_green(api_help_cmd)}` to get help for a specific API type or rule.\n"
         )
 
-    def _print_all_backends(self) -> None:
+    def _print_all_backends(self, include_experimental: bool) -> None:
         self._print_title("Backends")
         print(
             softwrap(
@@ -360,6 +360,8 @@ def _print_all_backends(self) -> None:
         provider_col_width = 3 + max(map(len, (info.provider for info in backends.values())))
         enabled_col_width = 4
         for info in backends.values():
+            if not (include_experimental or info.enabled) and ".experimental." in info.name:
+                continue
             enabled = "[*] " if info.enabled else "[ ] "
             name_col_width = max(
                 len(info.name) + 1, self._width - enabled_col_width - provider_col_width


Test patch:
Repository: pantsbuild/pants

Issue:
`help` output does not mention `symbols`
**Describe the bug**
`./pants help symbols` was added in #18378. But `./pants help` and `./pants help-advanced` do not mention it.

Also, `./pants help [name]` should also mention `symbols` as a valid type of name.

**Pants version**
2.16.0a0

**OS**
both


Discussion:

Resolving patch:
diff --git a/src/python/pants/help/help_printer.py b/src/python/pants/help/help_printer.py
--- a/src/python/pants/help/help_printer.py
+++ b/src/python/pants/help/help_printer.py
@@ -419,6 +419,11 @@ def print_cmd(args: str, desc: str):
         print_cmd("help tools", "List all external tools.")
         print_cmd("help backends", "List all available backends.")
         print_cmd("help-advanced backends", "List all backends, including experimental/preview.")
+        print_cmd("help symbols", "List available BUILD file symbols.")
+        print_cmd(
+            "help-advanced symbols",
+            "List all available BUILD file symbols, including target types.",
+        )
         print_cmd("help api-types", "List all plugin API types.")
         print_cmd("help global", "Help for global options.")
         print_cmd("help-advanced global", "Help for global advanced options.")


Test patch:
Repository: pantsbuild/pants

Issue:
docs: `adhoc_tool` example field values swapped
              When looking at the rendered docs it was much easier to spot that the example field values here are swapped (files vs directories). 👀

_Originally posted by @kaos in https://github.com/pantsbuild/pants/pull/18237#discussion_r1184219518_
            


Discussion:
<img width="537" alt="image" src="https://user-images.githubusercontent.com/72965/236041176-8bd9779c-2244-4608-9161-d178b43e9af6.png">


Resolving patch:
diff --git a/src/python/pants/backend/adhoc/target_types.py b/src/python/pants/backend/adhoc/target_types.py
--- a/src/python/pants/backend/adhoc/target_types.py
+++ b/src/python/pants/backend/adhoc/target_types.py
@@ -257,8 +257,8 @@ class AdhocToolTarget(Target):
                 {AdhocToolRunnableField.alias}=":python_source",
                 {AdhocToolArgumentsField.alias}=[""],
                 {AdhocToolExecutionDependenciesField.alias}=[":scripts"],
-                {AdhocToolOutputDirectoriesField.alias}=["logs/my-script.log"],
-                {AdhocToolOutputFilesField.alias}=["results/"],
+                {AdhocToolOutputDirectoriesField.alias}=["results/"],
+                {AdhocToolOutputFilesField.alias}=["logs/my-script.log"],
             )
 
             shell_sources(name="scripts")


Test patch:
Repository: pantsbuild/pants

Issue:
docs: `adhoc_tool` example field values swapped
              When looking at the rendered docs it was much easier to spot that the example field values here are swapped (files vs directories). 👀

_Originally posted by @kaos in https://github.com/pantsbuild/pants/pull/18237#discussion_r1184219518_
            


Discussion:
<img width="537" alt="image" src="https://user-images.githubusercontent.com/72965/236041176-8bd9779c-2244-4608-9161-d178b43e9af6.png">


Resolving patch:
diff --git a/src/python/pants/backend/adhoc/target_types.py b/src/python/pants/backend/adhoc/target_types.py
--- a/src/python/pants/backend/adhoc/target_types.py
+++ b/src/python/pants/backend/adhoc/target_types.py
@@ -264,8 +264,8 @@ class AdhocToolTarget(Target):
                 {AdhocToolRunnableField.alias}=":python_source",
                 {AdhocToolArgumentsField.alias}=[""],
                 {AdhocToolExecutionDependenciesField.alias}=[":scripts"],
-                {AdhocToolOutputDirectoriesField.alias}=["logs/my-script.log"],
-                {AdhocToolOutputFilesField.alias}=["results/"],
+                {AdhocToolOutputDirectoriesField.alias}=["results/"],
+                {AdhocToolOutputFilesField.alias}=["logs/my-script.log"],
             )
 
             shell_sources(name="scripts")


Test patch:
Repository: pantsbuild/pants

Issue:
`[docker].registries` help omits `use_local_alias` feature (in 2.16+)
:cry: 


Discussion:
doh

Resolving patch:
diff --git a/src/python/pants/backend/docker/subsystems/docker_options.py b/src/python/pants/backend/docker/subsystems/docker_options.py
--- a/src/python/pants/backend/docker/subsystems/docker_options.py
+++ b/src/python/pants/backend/docker/subsystems/docker_options.py
@@ -66,6 +66,7 @@ def env_vars(self) -> tuple[str, ...]:
                         "extra_image_tags": [],
                         "skip_push": bool,
                         "repository": str,
+                        "use_local_alias": bool,
                     },
                     ...
                 }
@@ -91,6 +92,10 @@ def env_vars(self) -> tuple[str, ...]:
             `docker_image.repository` or the default repository. Using the placeholders
             `{target_repository}` or `{default_repository}` those overridden values may be
             incorporated into the registry specific repository value.
+
+            If `use_local_alias` is true, a built image is additionally tagged locally using the
+            registry alias as the value for repository (i.e. the additional image tag is not pushed)
+            and will be used for any `pants run` requests.
             """
         ),
         fromfile=True,


Test patch:
Repository: pantsbuild/pants

Issue:
`[docker].registries` help omits `use_local_alias` feature (in 2.16+)
:cry: 


Discussion:
doh

Resolving patch:
diff --git a/src/python/pants/backend/docker/subsystems/docker_options.py b/src/python/pants/backend/docker/subsystems/docker_options.py
--- a/src/python/pants/backend/docker/subsystems/docker_options.py
+++ b/src/python/pants/backend/docker/subsystems/docker_options.py
@@ -88,6 +88,7 @@ def iter_path_entries():
                         "extra_image_tags": [],
                         "skip_push": bool,
                         "repository": str,
+                        "use_local_alias": bool,
                     },
                     ...
                 }
@@ -113,6 +114,10 @@ def iter_path_entries():
             `docker_image.repository` or the default repository. Using the placeholders
             `{target_repository}` or `{default_repository}` those overridden values may be
             incorporated into the registry specific repository value.
+
+            If `use_local_alias` is true, a built image is additionally tagged locally using the
+            registry alias as the value for repository (i.e. the additional image tag is not pushed)
+            and will be used for any `pants run` requests.
             """
         ),
         fromfile=True,


Test patch:
Repository: pantsbuild/pants

Issue:
`AdhocProcessRequest` isn't replacing `$0` correctly
**Describe the bug**
From https://pantsbuild.slack.com/archives/C0D7TNJHL/p1684255827991839

```
file(
    name="downloaded-jq",
    source = http_source(
        len = 3953824,
        sha256 = "af986793a515d500ab2d35f8d2aecd656e764504b789b66d7e1a0b727a124c44",
        url = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64",
    ),
)
shell_command(
    name = "sandboxed-jq",
    command="chmod +x jq-linux64",
    tools = ["chmod"],
    execution_dependencies=[":downloaded-jq"],
    output_directories = ["."],
)
run_shell_command(
    name = "jq",
    command=f"{{chroot}}/{build_file_dir() / 'jq-linux64'}",
    execution_dependencies=[":sandboxed-jq"],
    workdir="/",
)
```

Run with:
`$ pants run //:jq -- --help`

yields usage:
```
Usage:  /tmp/pants-sandbox-zLIAv5/3rdparty/tools/jq-linux64 [options] <jq filter> [file...]
        /tmp/pants-sandbox-zLIAv5/3rdparty/tools/jq-linux64 [options] --args <jq filter> [strings...]
        /tmp/pants-sandbox-zLIAv5/3rdparty/tools/jq-linux64 [options] --jsonargs <jq filter> [JSON_TEXTS...]
```

**Pants version**
`main`

**OS**
Linux

**Additional info**




Discussion:
CC @chrisjrn 
Changing the `argv` inside `_prepare_process_request_from_target` to `f'exec -a {shell_command.address.spec} {command}',` _almost_ does the right thing, but the quoting is off.

It produces `/usr/bin/bash -c $'\'exec -a //:sandboxed-jq chmod +x jq-linux64\''`, but what we want is `/usr/bin/bash -c $'exec -a //:sandboxed-jq chmod +x jq-linux64'`
@thejcannon This is probably something where you want to start nesting `shlex.quote` calls. Maybe?
Also the code I'm editing is the wrong codepath :sweat_smile: 

Resolving patch:
diff --git a/src/python/pants/backend/shell/target_types.py b/src/python/pants/backend/shell/target_types.py
--- a/src/python/pants/backend/shell/target_types.py
+++ b/src/python/pants/backend/shell/target_types.py
@@ -266,7 +266,15 @@ class ShellSourcesGeneratorTarget(TargetFilesGenerator):
 class ShellCommandCommandField(StringField):
     alias = "command"
     required = True
-    help = "Shell command to execute.\n\nThe command is executed as 'bash -c <command>' by default."
+    help = help_text(
+        """
+        Shell command to execute.
+
+        The command is executed as 'bash -c <command>' by default. If you want to invoke a binary
+        use `exec -a $0 <binary> <args>` as the command so that the binary gets the correct `argv[0]`
+        set.
+        """
+    )
 
 
 class ShellCommandOutputFilesField(AdhocToolOutputFilesField):


Test patch:
Repository: pantsbuild/pants

Issue:
`AdhocProcessRequest` isn't replacing `$0` correctly
**Describe the bug**
From https://pantsbuild.slack.com/archives/C0D7TNJHL/p1684255827991839

```
file(
    name="downloaded-jq",
    source = http_source(
        len = 3953824,
        sha256 = "af986793a515d500ab2d35f8d2aecd656e764504b789b66d7e1a0b727a124c44",
        url = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64",
    ),
)
shell_command(
    name = "sandboxed-jq",
    command="chmod +x jq-linux64",
    tools = ["chmod"],
    execution_dependencies=[":downloaded-jq"],
    output_directories = ["."],
)
run_shell_command(
    name = "jq",
    command=f"{{chroot}}/{build_file_dir() / 'jq-linux64'}",
    execution_dependencies=[":sandboxed-jq"],
    workdir="/",
)
```

Run with:
`$ pants run //:jq -- --help`

yields usage:
```
Usage:  /tmp/pants-sandbox-zLIAv5/3rdparty/tools/jq-linux64 [options] <jq filter> [file...]
        /tmp/pants-sandbox-zLIAv5/3rdparty/tools/jq-linux64 [options] --args <jq filter> [strings...]
        /tmp/pants-sandbox-zLIAv5/3rdparty/tools/jq-linux64 [options] --jsonargs <jq filter> [JSON_TEXTS...]
```

**Pants version**
`main`

**OS**
Linux

**Additional info**




Discussion:
CC @chrisjrn 
Changing the `argv` inside `_prepare_process_request_from_target` to `f'exec -a {shell_command.address.spec} {command}',` _almost_ does the right thing, but the quoting is off.

It produces `/usr/bin/bash -c $'\'exec -a //:sandboxed-jq chmod +x jq-linux64\''`, but what we want is `/usr/bin/bash -c $'exec -a //:sandboxed-jq chmod +x jq-linux64'`
@thejcannon This is probably something where you want to start nesting `shlex.quote` calls. Maybe?
Also the code I'm editing is the wrong codepath :sweat_smile: 

Resolving patch:
diff --git a/src/python/pants/backend/shell/target_types.py b/src/python/pants/backend/shell/target_types.py
--- a/src/python/pants/backend/shell/target_types.py
+++ b/src/python/pants/backend/shell/target_types.py
@@ -266,7 +266,15 @@ class ShellSourcesGeneratorTarget(TargetFilesGenerator):
 class ShellCommandCommandField(StringField):
     alias = "command"
     required = True
-    help = "Shell command to execute.\n\nThe command is executed as 'bash -c <command>' by default."
+    help = help_text(
+        """
+        Shell command to execute.
+
+        The command is executed as 'bash -c <command>' by default. If you want to invoke a binary
+        use `exec -a $0 <binary> <args>` as the command so that the binary gets the correct `argv[0]`
+        set.
+        """
+    )
 
 
 class ShellCommandOutputsField(StringSequenceField):


Test patch:
Repository: pantsbuild/pants

Issue:
The `InvalidEntryPoint` should subclass `InvalidFieldException`
That sounds good to have `InvalidEntryPoint` subclass `InvalidFieldException`, definitely. And makes sense if you want to do in a followup to keep this PR better scoped.

_Originally posted by @Eric-Arellano in https://github.com/pantsbuild/pants/pull/12414#discussion_r677074818_


Discussion:

Resolving patch:
diff --git a/src/python/pants/backend/python/util_rules/package_dists.py b/src/python/pants/backend/python/util_rules/package_dists.py
--- a/src/python/pants/backend/python/util_rules/package_dists.py
+++ b/src/python/pants/backend/python/util_rules/package_dists.py
@@ -105,7 +105,7 @@ class TargetNotExported(SetupPyError):
     """Indicates a target that was expected to be exported is not."""
 
 
-class InvalidEntryPoint(SetupPyError):
+class InvalidEntryPoint(SetupPyError, InvalidFieldException):
     """Indicates that a specified binary entry point was invalid."""
 
 


Test patch:
Repository: pantsbuild/pants

Issue:
Update FaaS documentation for new layout="zip"
**Is your feature request related to a problem? Please describe.**

In #19076, I implement a new method for building AWS Lambda artefacts. This will require changes to https://www.pantsbuild.org/docs/awslambda-python and https://www.pantsbuild.org/docs/google-cloud-function-python.

**Describe the solution you'd like**
- Update those pages.
- Fix typo https://github.com/pantsbuild/pants/pull/19122#discussion_r1205972422

**Describe alternatives you've considered**
N/A

**Additional context**
Potentially also update for #18880, if that's implemented.


Discussion:

Resolving patch:
diff --git a/src/python/pants/backend/python/subsystems/lambdex.py b/src/python/pants/backend/python/subsystems/lambdex.py
--- a/src/python/pants/backend/python/subsystems/lambdex.py
+++ b/src/python/pants/backend/python/subsystems/lambdex.py
@@ -7,6 +7,7 @@
 from pants.backend.python.target_types import ConsoleScript
 from pants.engine.rules import collect_rules
 from pants.option.option_types import EnumOption
+from pants.util.docutil import doc_url
 from pants.util.strutil import softwrap
 
 
@@ -40,8 +41,8 @@ class Lambdex(PythonToolBase):
         ),
         removal_version="2.19.0.dev0",
         removal_hint=softwrap(
-            """
-            Remove the whole [lambdex] section, as Lambdex is deprecated and its functionality be
+            f"""
+            Remove the whole [lambdex] section, as Lambdex is deprecated and its functionality will be
             removed. If you have `layout = "zip"`, no further action is required, as you are already using
             the recommended layout.
 
@@ -50,6 +51,11 @@ class Lambdex(PythonToolBase):
             as recommended by cloud vendors.  (If you are using `python_awslambda`, you will need to
             also update the handlers configured in the cloud from `lambdex_handler.handler` to
             `lambda_function.handler`.)
+
+            See the docs for more details:
+
+            * {doc_url('awslambda-python#migrating-from-pants-216-and-earlier')}
+            * {doc_url('google-cloud-function-python#migrating-from-pants-216-and-earlier')}
             """
         ),
     )


Test patch:
Repository: pantsbuild/pants

Issue:
Update FaaS documentation for new layout="zip"
**Is your feature request related to a problem? Please describe.**

In #19076, I implement a new method for building AWS Lambda artefacts. This will require changes to https://www.pantsbuild.org/docs/awslambda-python and https://www.pantsbuild.org/docs/google-cloud-function-python.

**Describe the solution you'd like**
- Update those pages.
- Fix typo https://github.com/pantsbuild/pants/pull/19122#discussion_r1205972422

**Describe alternatives you've considered**
N/A

**Additional context**
Potentially also update for #18880, if that's implemented.


Discussion:

Resolving patch:
diff --git a/src/python/pants/backend/python/subsystems/lambdex.py b/src/python/pants/backend/python/subsystems/lambdex.py
--- a/src/python/pants/backend/python/subsystems/lambdex.py
+++ b/src/python/pants/backend/python/subsystems/lambdex.py
@@ -8,6 +8,7 @@
 from pants.base.deprecated import warn_or_error
 from pants.engine.rules import collect_rules
 from pants.option.option_types import EnumOption
+from pants.util.docutil import doc_url
 from pants.util.strutil import softwrap
 
 
@@ -64,6 +65,11 @@ def warn_for_layout(self, target_alias: str) -> None:
                     You can also explicitly set `layout = "lambdex"` to silence this warning and
                     continue using the Lambdex-based layout in this release of Pants. This layout
                     will disappear in future.
+
+                    See the docs for more details:
+
+                    * {doc_url('awslambda-python#migrating-from-pants-216-and-earlier')}
+                    * {doc_url('google-cloud-function-python#migrating-from-pants-216-and-earlier')}
                     """
                 ),
             )


Test patch:
Repository: pantsbuild/pants

Issue:
"Dependencies with docker_image targets" shorthand example doesn't find the image dependency
**Describe the bug**
https://www.pantsbuild.org/docs/helm-deployments#dependencies-with-docker_image-targets

```
$ cat src/deployment/BUILD 
#Overrides the `image` value for the chart using the target address for the first-party docker image.
helm_deployment(dependencies=["src/chart"],
                sources=["common-values.yaml"],
                values={"image": "src/docker"})

$ ./pants dependencies src/deployment:deployment
src/chart:chart
$ cat src/deployment/BUILD 
#Overrides the `image` value for the chart using the target address for the first-party docker image.
helm_deployment(dependencies=["src/chart"],
                sources=["common-values.yaml"],
                values={"image": "src/docker:docker"})
$ ./pants dependencies src/deployment:deployment
src/chart:chart
src/docker:docker
```

Note the need for `:docker`, which is not in the example.

**Pants version**
2.16.0.dev7

**OS**
Linux

**Additional info**
https://github.com/cburroughs/example-python/commit/1289d12c9a0c2620add1a6230fb985c8dad6d38f



Discussion:

Resolving patch:
diff --git a/src/python/pants/backend/helm/target_types.py b/src/python/pants/backend/helm/target_types.py
--- a/src/python/pants/backend/helm/target_types.py
+++ b/src/python/pants/backend/helm/target_types.py
@@ -8,6 +8,7 @@
 
 from pants.backend.helm.resolve.remotes import ALL_DEFAULT_HELM_REGISTRIES
 from pants.base.deprecated import warn_or_error
+from pants.base.glob_match_error_behavior import GlobMatchErrorBehavior
 from pants.core.goals.package import OutputPathField
 from pants.core.goals.test import TestTimeoutField
 from pants.engine.internals.native_engine import AddressInput
@@ -444,6 +445,7 @@ class HelmDeploymentSkipCrdsField(BoolField):
 class HelmDeploymentSourcesField(MultipleSourcesField):
     default = ("*.yaml", "*.yml")
     expected_file_extensions = (".yaml", ".yml")
+    default_glob_match_error_behavior = GlobMatchErrorBehavior.ignore
     help = "Helm configuration files for a given deployment."
 
 


Test patch: