click: Longest option argument not used as internal/variable name
It seems that with 7.0 the longest option argument isn’t being used as the internal and variable name.
the internal name is generated automatically by taking the longest argument
import click
import click.testing
print(click.__version__)
@click.command()
@click.option(
'--temp',
'--temporary',
'temporary',
)
def good(temporary):
pass
@click.command()
@click.option(
'--temp',
'--temporary',
)
def bad(temporary):
pass
def click_runner(command):
print(command.name)
runner = click.testing.CliRunner()
result = runner.invoke(
command,
[],
catch_exceptions=False,
)
print(result.output)
click_runner(command=good)
click_runner(command=bad)
https://repl.it/@altendky/click-67-unexpected-keyword-argument-1
6.7
good
bad
https://repl.it/@altendky/click-70-unexpected-keyword-argument-1
7.0
good
bad
Traceback (most recent call last):
File "python", line 37, in <module>
File "python", line 32, in click_runner
TypeError: bad() got an unexpected keyword argument 'temp'
https://repl.it/@altendky/click-2e856a5-unexpected-keyword-argument
7.0
good
bad
Traceback (most recent call last):
File "python", line 37, in <module>
File "python", line 32, in click_runner
TypeError: bad() got an unexpected keyword argument 'temp'
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 31 (19 by maintainers)
It’s kind of tempting to deprecate this ‘feature’ and just say ‘if you have multiple of the longest type of parameter, specify the name’. Or maybe provide a marker so you don’t have to repeat. Maybe
'+--the-default'or somesuch? I dunno, explicit over implicit and all. This just seems like a bit of a fiddly mess with little benefit.Sorry, make it backwards compatible but fix the situation by deprecating the implicit order-based selection.
@davidism, I could presumably put together a PR… but this seems more like a policy decision than just a fix. If whoever would make that decision can let me know I can try to implement it (code/tests/docs).