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

Can't pass "help" parameter to click argument #24

Open
johnnymetz opened this issue Mar 10, 2021 · 1 comment
Open

Can't pass "help" parameter to click argument #24

johnnymetz opened this issue Mar 10, 2021 · 1 comment

Comments

@johnnymetz
Copy link

The following script works with the base click library but raises an exception with the django-click library.

import djclick as click

@click.command()
@click.argument("name", help="Some name")
def command(name):
    click.echo(f"Hi {name}!")

Exception:

Traceback (most recent call last):
  File "/app/./manage.py", line 22, in <module>
    main()
  File "/app/./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 244, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 37, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/core/management/commands/click1.py", line 6, in <module>
    def command(name):
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 168, in decorator
    _param_memo(f, ArgumentClass(param_decls, **attrs))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1984, in __init__
    Parameter.__init__(self, param_decls, required=required, **attrs)
TypeError: __init__() got an unexpected keyword argument 'help'
@techdragon
Copy link

techdragon commented Feb 22, 2023

I think you and I have both made this mistake @johnnymetz . Arguments don't have help text.

Someone else had the exact same problem here... pallets/click#466 ... so were also not the only two people 😄

Documenting Arguments

click.argument() does not take a help parameter. This is to follow the general convention of Unix tools of using arguments for only the most necessary things, and to document them in the command help text by referring to them by name.

Not sure if you want to close this as "user error" or wait for a reply, but id say its probably safe to say this isn't a bug in your library @GaretJax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants