-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Differentiate absence of value and value of absence for default and flag_value arguments
#3030
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
Conversation
dd7ccc2 to
7f2e7a4
Compare
03a4478 to
3adf6fd
Compare
|
From just a quick look at this, it is pretty cool! |
I solved 99% of issues and all tests are passing. I am now trying to hunt for even more obscure edge-cases and adding more tests. So I'm going to polish it in the next couple of days before requesting a proper review. In the meantime, I'm continue hacking on it in the open. |
|
Great work on tracking all this down, been following all week. |
I was indeed working the full week on that! 😮💨 |
I initially covered all the cases discussed over there to highlight your comment that, indeed, due to your changes in the pipeline, these types were fed as string type. In which case using But since we re-establish the legacy case of options with |
|
I just addressed all the comments. I'm ready for a final review. |
|
Looks like there is a docs build issue. I am going to merge then open it in another pr. @davidism I looked through all the comments and they were addressed. If you think they were not, I would suggest opening an issue and we can fix it there. The chain has gotten so long that it is hard to follow. I might have missed one. |
|
@kdeldycke Awesome work! |
|
Arf no don't merge yet! I wanted to squash some commits first! 😂 Well, whatever. I don't mind. |
|
Sorry, wasn't ready to merge this yet either. I still want to understand what's going on with I'm also not following the explanation #3030 (comment) of |
|
@Rowlando13 don't merge huge work commit chains like this in the future. It makes it way harder to use git blame in the future to figure out what the actual intended change was, as now we have to track the change through all the work and review as well. Either squash manually into a few commits, or use the Squash Merge feature in GitHub to create one commit. |
|
@davidism My bad. Will do in the future. I thought we wanted to preserve the process. |
|
@davidism shall I revert the merge? |
|
No it's fine, not a big deal, just something to keep in mind. |
Ah yes, sorry for the "strong langage"! 😅 I'm too deep into Click internals to have good judgment about what makes a visible breaking change from a mere behind the scene arrangement. So thanks for the feedbacks you made over the past few weeks (like the I just made a new PR to not declare |
I guess @davidism and I had a mutual implied understanding that PRs are OK to be messy while we work things up. Once we all agree about the quality, there's always time before merging to clean-up. For me being messy is part of the process, especially on big changes like this. I am not afraid of doing stupid stuff, making mistakes and backtracking on code. And doing all of that in the open. Writing code that way allow me to gather feedback early. And course-correct if I am not going in the right direction. Anyway, that is also part of learning to work together. No big deal indeed! I'll make sure to address everything so we can release 8.3.0 together and move on at a more relaxed pace! :) |
|
Not only I completely agree with @davidism , but I would go much further. Sit down and read http://who-t.blogspot.com/2009/12/on-commit-messages.html ... it is not about letting your dirty laundry hanging around (and nobody is interested in that), it is about creating good foundation for yourself when you study the change a year later. |
Hmm. Re-reading #2012 I think I overlooked a detail. Let's re-open it while I investigate. |
Tl;Dr: this PR makes user-provided values (like
None) first-class citizens.Description
UNSETsentinel value to track whendefaultandflag_valuehave been explicitly set by the user onParameter,OptionandArgumentNoneor any other Python value to be used asdefaultandflag_valueContext
The pandora box was open in Click 8.2.0 with an attempt to always returns the
flag_valueif an option gets activated by its environment variable:flag_valueis not taken into account withenvvar#2746Another patch in Click 8.2.0 tried to fix how
flag_valuegets aligned to itsdefault:The effect of these patches were reported after 8.2.0 release, and uncovered how tangled the flag logic is regarding its
default,flag_value,typeandenvvarparameters:A first attempt to fix these issues was made in Click 8.2.1:
As I was aware of some of these edge-cases in 2023, I tackled this challenge and made a big PR to reconcile everything:
default,flag_valueandtypeparameters for flag options #2956This was released as Click 8.2.2. But it was not enough and even more nastier edge-cases were spotted (see the Progress section below). 8.2.2 was finally yanked to prevent widespread frustration.
The situation cannot be fixed with trivial changes as we are confronted with internal design limits. This PR is trying to fix all this mess.
Progress
Currently playing Whac-A-Mole, but ultimate goal is to fix the following issues:
Binary flags vs
default=None: semantics and issue with prompt #1992Status: ✅ 100% fixed
Proof:
click/tests/test_termui.py
Lines 492 to 554 in 14e6cee
flag_valueis passed throughParamType.convert#2012Status: ✅ 100% fixed
Proof:
click/tests/test_options.py
Lines 1749 to 1817 in da07421
click/tests/test_options.py
Lines 1850 to 1864 in f9d006e
click/tests/test_options.py
Lines 1727 to 1744 in f9d006e
Support default for arguments with multiple values #2164
Status: ✅ 100% fixed
Proof:
click/tests/test_arguments.py
Lines 388 to 392 in 3bd9e22
make
flag_value=Noneactually set flag value toNone#2514Status: ✅ 100% fixed
Proof:
click/tests/test_options.py
Lines 1278 to 1279 in 14e6cee
The
flag_valueshadowsdefaultinclick.option()#2610Status: ✅ 100% fixed
Proof:
click/tests/test_options.py
Lines 1697 to 1718 in 14e6cee
setandfrozenset(anddict?) as native Click types #3036Click 8.2.2 breaks auto-reloader-active on flask --debug #3024
Status: ✅ 100% fixed
Proof:
click/tests/test_options.py
Lines 1254 to 1255 in 14e6cee
click/tests/test_options.py
Lines 1656 to 1694 in 14e6cee
click/tests/test_options.py
Lines 1697 to 1722 in 9fcd409
click/tests/test_basic.py
Lines 279 to 297 in 373429e
click/docs/options.md
Lines 317 to 329 in 373429e
click/tests/test_options.py
Lines 1725 to 1746 in b6db38e