Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] TypeError: 'dict_values' object is not subscriptable #95

Closed
Freed-Wu opened this issue Aug 28, 2022 · 4 comments
Closed

[bug] TypeError: 'dict_values' object is not subscriptable #95

Freed-Wu opened this issue Aug 28, 2022 · 4 comments
Assignees
Labels
help-wanted We need help invalid Doesn't seem right p1-important High priority

Comments

@Freed-Wu
Copy link
Contributor

I try to generate completes for tensorboard tensorflow/tensorboard#5902, only zsh failed:

❯ tensorboard --print-completion zsh
TensorFlow installation not found - running with reduced feature set.
Traceback (most recent call last):
  File "/usr/bin/tensorboard", line 33, in <module>
    sys.exit(load_entry_point('tensorboard==2.9.1', 'console_scripts', 'tensorboard')())
  File "/usr/lib/python3.10/site-packages/tensorboard/main.py", line 46, in run_main
    app.run(tensorboard.main, flags_parser=tensorboard.configure)
  File "/usr/lib/python3.10/site-packages/absl/app.py", line 304, in run
    args = _run_init(
  File "/usr/lib/python3.10/site-packages/absl/app.py", line 373, in _run_init
    args = _register_and_parse_flags_with_usage(
  File "/usr/lib/python3.10/site-packages/absl/app.py", line 220, in _register_and_parse_flags_with_usage
    args_to_main = flags_parser(original_argv)
  File "/usr/lib/python3.10/site-packages/tensorboard/program.py", line 236, in configure
    flags = base_parser.parse_args(argv[1:])  # Strip binary name from argv.
  File "/usr/lib/python3.10/argparse.py", line 1826, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.10/site-packages/absl/flags/argparse_flags.py", line 168, in parse_known_args
    namespace, args = super(ArgumentParser, self).parse_known_args(
  File "/usr/lib/python3.10/argparse.py", line 1859, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 2068, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python3.10/argparse.py", line 2008, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python3.10/argparse.py", line 1936, in take_action
    action(self, namespace, argument_values, option_string)
  File "/home/wzy/.local/lib/python3.10/site-packages/shtab/__init__.py", line 787, in __call__
    print(complete(parent or parser, values, preamble=preamble))
  File "/home/wzy/.local/lib/python3.10/site-packages/shtab/__init__.py", line 776, in complete
    return completer(
  File "/home/wzy/.local/lib/python3.10/site-packages/shtab/__init__.py", line 509, in complete_zsh
    "cmd": prog, "arguments": [
  File "/home/wzy/.local/lib/python3.10/site-packages/shtab/__init__.py", line 510, in <listcomp>
    format_optional(opt)
  File "/home/wzy/.local/lib/python3.10/site-packages/shtab/__init__.py", line 492, in format_optional
    (choice_type2fn[opt.choices[0].type] if isinstance(opt.choices[0], Choice) else
TypeError: 'dict_values' object is not subscriptable

From command line, it also failed.

Thanks.

@Simon-1-1
Copy link

Are you using the choices= parameter of add_argument? If so, make sure you are providing a tuple. I provided a list in my case, which resulted in this error.

@Freed-Wu
Copy link
Contributor Author

OK, good suggestion. However, it still is a bug which need to be fixed 🐛.

@omesser omesser added help-wanted We need help p1-important High priority labels Mar 15, 2023
@casperdcl
Copy link
Collaborator

As per https://docs.python.org/3/library/argparse.html#choices it seems any sequence should be supported. I don't think that includes dict (assert not isinstance(dict, typing.Sequence))

@kshitiz305
Copy link

So what shall be the fix be ?

@casperdcl casperdcl added the invalid Doesn't seem right label Jul 8, 2023
@casperdcl casperdcl self-assigned this Jul 8, 2023
@casperdcl casperdcl closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted We need help invalid Doesn't seem right p1-important High priority
Projects
None yet
Development

No branches or pull requests

5 participants