-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Longest option argument not used as internal/variable name #1140
Comments
Seems to relate to #793/#794 where a different part of the docs were referenced. So I guess the question is which one do we want? options: Lines 41 to 43 in b1b8c48
vs parameters: Lines 93 to 95 in 2c622ee
|
@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). |
Thanks! Seems better to revert to the old behavior and update the docs. |
@davidism should the PR be against |
It should be against 7.x. You can add a change entry that points to the pr now that it's submitted. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@kiwi0fruit are you referring to #1149 not properly reverting functionality? |
This comment was marked as off-topic.
This comment was marked as off-topic.
I'm presently setting up the tests against 6.7 as the reference since the point is to revert to that functionality, but with consistent docs. |
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 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, make it backwards compatible but fix the situation by deprecating the implicit order-based selection. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@kiwi0fruit please stop having this discussion. 6 -> 7 was a major version, it's not required to maintain compatibility. That said, we've already acknowledged that we want to adjust the behavior. If you want to provide constructive feedback, look into comparing the code and behaviors of the two versions with actual examples. |
The docs. Though admittedly above I believe I linked latest docs, not 6.7 docs. But, even 6.7 docs were inconsistent. options: Lines 19 to 20 in df0e37d
parameters: Lines 83 to 88 in df0e37d
I also checked out 6.7 and pulled a branch to validate tests against. The tests in #1149 did not pass so I adjusted them as follows so we could have an actual 6.7 reference. I am happy to add more cases to that branch so as to keep them all together. @pytest.mark.parametrize('option_args,expected', [
(['--aggressive', '--all', '-a'], 'all'),
(['--first', '--second', '--third', '-a', '-b', '-c'], 'third'),
(['--apple', '--banana', '--cantaloupe', '-a', '-b', '-c'], 'cantaloupe'),
(['--cantaloupe', '--banana', '--apple', '-c', '-b', '-a'], 'apple'),
(['-a', '-b', '-c'], 'c'),
(['-c', '-b', '-a'], 'a'),
(['-a', '--apple', '-b', '--banana', '-c', '--cantaloupe'], 'cantaloupe'),
(['-c', '-a', '--cantaloupe', '-b', '--banana', '--apple'], 'apple'),
(['--from', '-f', '_from'], '_from'),
(['--return', '-r', '_ret'], '_ret'),
(['-f', '-r', '--from', '--read'], 'read'),
(['-w', '-t', '--write', '--to'], 'to'),
]) Sure, 6->7 is a major version but I wouldn't want to change just because. But, I think that the interface is bad if nothing else because we seem to have three definitions that all conflict (options: "first long option", parameters: "longest argument", code: picks last long). How about we make the rule super simple and just require people to be explicit in the face of ambiguity. shrug I would think the Anyways, I'll hold off on making any changes to the PR until we decide what behavior we really want. At this point we may have to consider that 6->7 breaking may not be preferred but was 'technically acceptable' while reverting the functionality in 7->7.1 (or whatever this might end up in) |
This comment was marked as off-topic.
This comment was marked as off-topic.
@kiwi0fruit, I never meant to advocate changing the interface from 6.7. I just made the mistake of looking at the docs rather than the code. At which point we could even argue that 6.7 actual behavior was a bug since it didn't match either piece of documentation. But still, when you are stuck with 3 inconsistent 'policies' and now have new functionality in a new major version... Let's at least consider where we should end up. Then how to get there with the least surprise and frustration. Side note, this made me start looking into actual CI. Not just build on each commit, but integrating latest on each build. Not that this change was that horrible, it just triggered me to actually act and try to setup CI with Tox, which was reasonably painful. I added a few extra jobs to do latest deps, latest --pre deps, and vcs deps. Hopefully this will help us catch these things prior to release. Though having a prerelease on PyPI could also help encourage people to use things before a full release. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@kiwi0fruit, you dislike requiring an explicit decision of the developer? |
This comment was marked as off-topic.
This comment was marked as off-topic.
@kiwi0fruit, consider that this ticket exists exactly because we observed the change... |
I haven't thought it through a lot but just so we have something (more) concrete to consider...
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I considered there being possible improvements to automatic selection. It didn't seem like they would provide much value over just checking for an explicit choice by the developer. Explicit has the upsides of simple everything for everyone. Nobody has to remember anything beyond the explicit indicator. |
And a single extra character seems like a minimal burden. |
So we have two things to address. How do we handle the documentation/code disagreement right now and where do we want to go in the future. Right now we should do one of...
Later, none or more of...
And maybe also consider doing prereleases in hopes to catch stuff like this before release next time. Maybe, I dunno. (@sirosen) |
Well, totally forgot this discussion happened, then did some digging here #1420 (comment) when it was brought up again. Based on that, my decision is that the change to use the first argument, preferring double dash over single dash, was intentional, and the docs should be updated to be clear about the rules as they currently work. |
It seems that with 7.0 the longest option argument isn't being used as the internal and variable name.
click/docs/parameters.rst
Lines 93 to 95 in 2c622ee
https://repl.it/@altendky/click-67-unexpected-keyword-argument-1
https://repl.it/@altendky/click-70-unexpected-keyword-argument-1
https://repl.it/@altendky/click-2e856a5-unexpected-keyword-argument
The text was updated successfully, but these errors were encountered: