prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  shell completion issue with dvc 3.11.0 release build
  # Bug Report
  
  👋 while trying to upgrade dvc to the latest release, I ran into the shell completion failure
  
  ```
  Successfully installed dvc-3.11.0
  [31mERROR[39m: unexpected error - unsupported operand type(s) for %: 'tuple' and 'dict'
  
  [33mHaving any troubles?[0m Hit us up at [34mhttps://dvc.org/support[0m, we are always happy to help!
  [31mError:[0m Failure while executing; `\{\"SHELL\"=\>\"zsh\"\} /opt/homebrew/Cellar/dvc/3.11.0/bin/dvc completion -s zsh` exited with 255. Here's the output:
  ```
  
  relates to https://github.com/Homebrew/homebrew-core/pull/138416
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `dvc/commands/commit.py`
  Content:
  ```
  1 import argparse
  2 import logging
  3 
  4 from dvc.cli import completion
  5 from dvc.cli.command import CmdBase
  6 from dvc.cli.utils import append_doc_link
  7 
  8 logger = logging.getLogger(__name__)
  9 
  10 
  11 class CmdCommit(CmdBase):
  12     def run(self):
  13         from dvc.exceptions import DvcException
  14 
  15         if not self.args.targets:
  16             self.args.targets = [None]
  17 
  18         for target in self.args.targets:
  19             try:
  20                 self.repo.commit(
  21                     target,
  22                     with_deps=self.args.with_deps,
  23                     recursive=self.args.recursive,
  24                     force=self.args.force,
  25                 )
  26             except DvcException:
  27                 logger.exception("failed to commit%s", (" " + target) if target else "")
  28                 return 1
  29         return 0
  30 
  31 
  32 def add_parser(subparsers, parent_parser):
  33     COMMIT_HELP = (
  34         "Record changes to files or directories tracked by DVC"
  35         " by storing the current versions in the cache."
  36     )
  37 
  38     commit_parser = subparsers.add_parser(
  39         "commit",
  40         parents=[parent_parser],
  41         description=append_doc_link(COMMIT_HELP, "commit"),
  42         help=COMMIT_HELP,
  43         formatter_class=argparse.RawDescriptionHelpFormatter,
  44     )
  45     commit_parser.add_argument(
  46         "-f",
  47         "--force",
  48         action="store_true",
  49         default=False,
  50         help=(
  51             "Commit data even if hash values for dependencies or",
  52             "outputs did not change.",
  53         ),
  54     )
  55     commit_parser.add_argument(
  56         "-d",
  57         "--with-deps",
  58         action="store_true",
  59         default=False,
  60         help="Commit all dependencies of the specified target.",
  61     )
  62     commit_parser.add_argument(
  63         "-R",
  64         "--recursive",
  65         action="store_true",
  66         default=False,
  67         help="Commit cache for subdirectories of the specified directory.",
  68     )
  69     commit_parser.add_argument(
  70         "targets",
  71         nargs="*",
  72         help=(
  73             "Limit command scope to these tracked files/directories, "
  74             ".dvc files and stage names."
  75         ),
  76     ).complete = completion.DVCFILES_AND_STAGE
  77     commit_parser.set_defaults(func=CmdCommit)
  78
  ```
  
  Path: `dvc/commands/completion.py`
  Content:
  ```
  1 import argparse
  2 import logging
  3 
  4 from dvc.cli.command import CmdBaseNoRepo
  5 from dvc.cli.completion import PREAMBLE
  6 from dvc.cli.utils import append_doc_link
  7 from dvc.ui import ui
  8 
  9 logger = logging.getLogger(__name__)
  10 
  11 
  12 class CmdCompletion(CmdBaseNoRepo):
  13     def run(self):
  14         import shtab
  15 
  16         shell = self.args.shell
  17         parser = self.args.parser
  18         script = shtab.complete(parser, shell=shell, preamble=PREAMBLE)  # nosec B604
  19         ui.write(script, force=True)
  20         return 0
  21 
  22 
  23 def add_parser(subparsers, parent_parser):
  24     COMPLETION_HELP = "Generate shell tab completion."
  25     COMPLETION_DESCRIPTION = "Prints out shell tab completion scripts."
  26     completion_parser = subparsers.add_parser(
  27         "completion",
  28         parents=[parent_parser],
  29         description=append_doc_link(COMPLETION_DESCRIPTION, "completion"),
  30         help=COMPLETION_HELP,
  31         formatter_class=argparse.RawDescriptionHelpFormatter,
  32     )
  33     completion_parser.add_argument(
  34         "-s",
  35         "--shell",
  36         help="Shell syntax for completions.",
  37         default="bash",
  38         choices=["bash", "zsh"],
  39     )
  40     completion_parser.set_defaults(func=CmdCompletion)
  41
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/dvc/commands/commit.py b/dvc/commands/commit.py
  --- a/dvc/commands/commit.py
  +++ b/dvc/commands/commit.py
  @@ -48,8 +48,8 @@
           action="store_true",
           default=False,
           help=(
  -            "Commit data even if hash values for dependencies or",
  -            "outputs did not change.",
  +            "Commit data even if hash values for dependencies or "
  +            "outputs did not change."
           ),
       )
       commit_parser.add_argument(
  diff --git a/dvc/commands/completion.py b/dvc/commands/completion.py
  --- a/dvc/commands/completion.py
  +++ b/dvc/commands/completion.py
  @@ -9,6 +9,9 @@
   logger = logging.getLogger(__name__)
   
   
  +SUPPORTED_SHELLS = ["bash", "zsh"]
  +
  +
   class CmdCompletion(CmdBaseNoRepo):
       def run(self):
           import shtab
  @@ -35,6 +38,6 @@
           "--shell",
           help="Shell syntax for completions.",
           default="bash",
  -        choices=["bash", "zsh"],
  +        choices=SUPPORTED_SHELLS,
       )
       completion_parser.set_defaults(func=CmdCompletion)
  
verification_info: {"golden_diff": "diff --git a/dvc/commands/commit.py b/dvc/commands/commit.py\n--- a/dvc/commands/commit.py\n+++ b/dvc/commands/commit.py\n@@ -48,8 +48,8 @@\n         action=\"store_true\",\n         default=False,\n         help=(\n-            \"Commit data even if hash values for dependencies or\",\n-            \"outputs did not change.\",\n+            \"Commit data even if hash values for dependencies or \"\n+            \"outputs did not change.\"\n         ),\n     )\n     commit_parser.add_argument(\ndiff --git a/dvc/commands/completion.py b/dvc/commands/completion.py\n--- a/dvc/commands/completion.py\n+++ b/dvc/commands/completion.py\n@@ -9,6 +9,9 @@\n logger = logging.getLogger(__name__)\n \n \n+SUPPORTED_SHELLS = [\"bash\", \"zsh\"]\n+\n+\n class CmdCompletion(CmdBaseNoRepo):\n     def run(self):\n         import shtab\n@@ -35,6 +38,6 @@\n         \"--shell\",\n         help=\"Shell syntax for completions.\",\n         default=\"bash\",\n-        choices=[\"bash\", \"zsh\"],\n+        choices=SUPPORTED_SHELLS,\n     )\n     completion_parser.set_defaults(func=CmdCompletion)\n", "issue": "shell completion issue with dvc 3.11.0 release build\n# Bug Report\r\n\r\n\ud83d\udc4b while trying to upgrade dvc to the latest release, I ran into the shell completion failure\r\n\r\n```\r\nSuccessfully installed dvc-3.11.0\r\n\u001b[31mERROR\u001b[39m: unexpected error - unsupported operand type(s) for %: 'tuple' and 'dict'\r\n\r\n\u001b[33mHaving any troubles?\u001b[0m Hit us up at \u001b[34mhttps://dvc.org/support\u001b[0m, we are always happy to help!\r\n\u001b[31mError:\u001b[0m Failure while executing; `\\{\\\"SHELL\\\"=\\>\\\"zsh\\\"\\} /opt/homebrew/Cellar/dvc/3.11.0/bin/dvc completion -s zsh` exited with 255. Here's the output:\r\n```\r\n\r\nrelates to https://github.com/Homebrew/homebrew-core/pull/138416\n", "before_files": [{"content": "import argparse\nimport logging\n\nfrom dvc.cli import completion\nfrom dvc.cli.command import CmdBase\nfrom dvc.cli.utils import append_doc_link\n\nlogger = logging.getLogger(__name__)\n\n\nclass CmdCommit(CmdBase):\n    def run(self):\n        from dvc.exceptions import DvcException\n\n        if not self.args.targets:\n            self.args.targets = [None]\n\n        for target in self.args.targets:\n            try:\n                self.repo.commit(\n                    target,\n                    with_deps=self.args.with_deps,\n                    recursive=self.args.recursive,\n                    force=self.args.force,\n                )\n            except DvcException:\n                logger.exception(\"failed to commit%s\", (\" \" + target) if target else \"\")\n                return 1\n        return 0\n\n\ndef add_parser(subparsers, parent_parser):\n    COMMIT_HELP = (\n        \"Record changes to files or directories tracked by DVC\"\n        \" by storing the current versions in the cache.\"\n    )\n\n    commit_parser = subparsers.add_parser(\n        \"commit\",\n        parents=[parent_parser],\n        description=append_doc_link(COMMIT_HELP, \"commit\"),\n        help=COMMIT_HELP,\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n    )\n    commit_parser.add_argument(\n        \"-f\",\n        \"--force\",\n        action=\"store_true\",\n        default=False,\n        help=(\n            \"Commit data even if hash values for dependencies or\",\n            \"outputs did not change.\",\n        ),\n    )\n    commit_parser.add_argument(\n        \"-d\",\n        \"--with-deps\",\n        action=\"store_true\",\n        default=False,\n        help=\"Commit all dependencies of the specified target.\",\n    )\n    commit_parser.add_argument(\n        \"-R\",\n        \"--recursive\",\n        action=\"store_true\",\n        default=False,\n        help=\"Commit cache for subdirectories of the specified directory.\",\n    )\n    commit_parser.add_argument(\n        \"targets\",\n        nargs=\"*\",\n        help=(\n            \"Limit command scope to these tracked files/directories, \"\n            \".dvc files and stage names.\"\n        ),\n    ).complete = completion.DVCFILES_AND_STAGE\n    commit_parser.set_defaults(func=CmdCommit)\n", "path": "dvc/commands/commit.py"}, {"content": "import argparse\nimport logging\n\nfrom dvc.cli.command import CmdBaseNoRepo\nfrom dvc.cli.completion import PREAMBLE\nfrom dvc.cli.utils import append_doc_link\nfrom dvc.ui import ui\n\nlogger = logging.getLogger(__name__)\n\n\nclass CmdCompletion(CmdBaseNoRepo):\n    def run(self):\n        import shtab\n\n        shell = self.args.shell\n        parser = self.args.parser\n        script = shtab.complete(parser, shell=shell, preamble=PREAMBLE)  # nosec B604\n        ui.write(script, force=True)\n        return 0\n\n\ndef add_parser(subparsers, parent_parser):\n    COMPLETION_HELP = \"Generate shell tab completion.\"\n    COMPLETION_DESCRIPTION = \"Prints out shell tab completion scripts.\"\n    completion_parser = subparsers.add_parser(\n        \"completion\",\n        parents=[parent_parser],\n        description=append_doc_link(COMPLETION_DESCRIPTION, \"completion\"),\n        help=COMPLETION_HELP,\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n    )\n    completion_parser.add_argument(\n        \"-s\",\n        \"--shell\",\n        help=\"Shell syntax for completions.\",\n        default=\"bash\",\n        choices=[\"bash\", \"zsh\"],\n    )\n    completion_parser.set_defaults(func=CmdCompletion)\n", "path": "dvc/commands/completion.py"}], "after_files": [{"content": "import argparse\nimport logging\n\nfrom dvc.cli import completion\nfrom dvc.cli.command import CmdBase\nfrom dvc.cli.utils import append_doc_link\n\nlogger = logging.getLogger(__name__)\n\n\nclass CmdCommit(CmdBase):\n    def run(self):\n        from dvc.exceptions import DvcException\n\n        if not self.args.targets:\n            self.args.targets = [None]\n\n        for target in self.args.targets:\n            try:\n                self.repo.commit(\n                    target,\n                    with_deps=self.args.with_deps,\n                    recursive=self.args.recursive,\n                    force=self.args.force,\n                )\n            except DvcException:\n                logger.exception(\"failed to commit%s\", (\" \" + target) if target else \"\")\n                return 1\n        return 0\n\n\ndef add_parser(subparsers, parent_parser):\n    COMMIT_HELP = (\n        \"Record changes to files or directories tracked by DVC\"\n        \" by storing the current versions in the cache.\"\n    )\n\n    commit_parser = subparsers.add_parser(\n        \"commit\",\n        parents=[parent_parser],\n        description=append_doc_link(COMMIT_HELP, \"commit\"),\n        help=COMMIT_HELP,\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n    )\n    commit_parser.add_argument(\n        \"-f\",\n        \"--force\",\n        action=\"store_true\",\n        default=False,\n        help=(\n            \"Commit data even if hash values for dependencies or \"\n            \"outputs did not change.\"\n        ),\n    )\n    commit_parser.add_argument(\n        \"-d\",\n        \"--with-deps\",\n        action=\"store_true\",\n        default=False,\n        help=\"Commit all dependencies of the specified target.\",\n    )\n    commit_parser.add_argument(\n        \"-R\",\n        \"--recursive\",\n        action=\"store_true\",\n        default=False,\n        help=\"Commit cache for subdirectories of the specified directory.\",\n    )\n    commit_parser.add_argument(\n        \"targets\",\n        nargs=\"*\",\n        help=(\n            \"Limit command scope to these tracked files/directories, \"\n            \".dvc files and stage names.\"\n        ),\n    ).complete = completion.DVCFILES_AND_STAGE\n    commit_parser.set_defaults(func=CmdCommit)\n", "path": "dvc/commands/commit.py"}, {"content": "import argparse\nimport logging\n\nfrom dvc.cli.command import CmdBaseNoRepo\nfrom dvc.cli.completion import PREAMBLE\nfrom dvc.cli.utils import append_doc_link\nfrom dvc.ui import ui\n\nlogger = logging.getLogger(__name__)\n\n\nSUPPORTED_SHELLS = [\"bash\", \"zsh\"]\n\n\nclass CmdCompletion(CmdBaseNoRepo):\n    def run(self):\n        import shtab\n\n        shell = self.args.shell\n        parser = self.args.parser\n        script = shtab.complete(parser, shell=shell, preamble=PREAMBLE)  # nosec B604\n        ui.write(script, force=True)\n        return 0\n\n\ndef add_parser(subparsers, parent_parser):\n    COMPLETION_HELP = \"Generate shell tab completion.\"\n    COMPLETION_DESCRIPTION = \"Prints out shell tab completion scripts.\"\n    completion_parser = subparsers.add_parser(\n        \"completion\",\n        parents=[parent_parser],\n        description=append_doc_link(COMPLETION_DESCRIPTION, \"completion\"),\n        help=COMPLETION_HELP,\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n    )\n    completion_parser.add_argument(\n        \"-s\",\n        \"--shell\",\n        help=\"Shell syntax for completions.\",\n        default=\"bash\",\n        choices=SUPPORTED_SHELLS,\n    )\n    completion_parser.set_defaults(func=CmdCompletion)\n", "path": "dvc/commands/completion.py"}]}