Longest option argument not used as internal/variable name
See original GitHub issueIt 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'
Issue Analytics
- State:
- Created 5 years ago
- Comments:31 (19 by maintainers)
Top Results From Across the Web
Passing argument as differently named parameter #949 - GitHub
It is possible to pass option as different variable name (e.g. ... becomes the internal parameter name which is also used as variable...
Read more >Parsing command-line arguments by Getopt::Long • GetoptLong
If the variable is defined as a function before GetoptLong() is called, it is treated as undefined. Please note your option names should...
Read more >Options (The GNU Awk User's Guide)
GNU-style long options consist of two dashes and a keyword. ... The -v option can only set one variable, but it can be...
Read more >5. Functions - gigamonkeys
A function's parameter list defines the variables that will be used to hold the arguments passed to the function when it's called. ......
Read more >Options Settings - R
Invoking options() with no arguments returns a list with the current values of the options. Note that not all options listed below are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.