-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fix CapturedCallable to work better with kwargs #121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the compromise this PR brings (fixing a bug with variadic keyword arguments
while not supporting positional only
and variadic positional arguments
) and think this will not adversely affect custom actions and custom graphs since we always send function arguments through the Parameter, and custom action mechanism in a keyword format.
Also thanks for the comments and tests in the code 💯 (they help lot to understand the problem and implemented solution).
So, +1 approval from my side. 🥇
Just update the changelog.d
directory (with hatch run docs:changelod
) with described bugfix (cuz it affects our users) and tick corresponding checkboxes under the Checklist
and Types of changes
in the PR Description 😄
…captured-callable # Conflicts: # vizro-core/changelog.d/20231024_101744_antony.milne_captured_callable.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great work! I just have one concern which I may have agreed to last night not grasping the full consequence, but maybe I am wrong. Let's see!
Thanks also for the extensive tests, really a joy to read actually!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, looks great! 🚀 Was mostly reading through this out of interest, the tests really helped understanding it. Is it worth adding a note to the docs for the custom charts/actions or do you think the error messages suffice to provide guidance? Either way is fine for me 👍
vizro-core/changelog.d/20231024_101744_antony.milne_captured_callable.md
Outdated
Show resolved
Hide resolved
…allable.md Co-authored-by: Li Nguyen <[email protected]> Signed-off-by: Antony Milne <[email protected]>
I think no need for anything in the narrative docs, since a user is so unlikely to ever try to do |
Description
#114 uncovered a bug with
CapturedCallable
. In short, this would work ok:And this would not:
Now they should both work ok.
We have already had a couple of very small bugs that I've known about for a while, where the following sorts of functions do not work with
CapturedCallable
:def function(*args)
def function(a, /)
Fixing the new
**kwargs
bug, which is an important case, makes it much harder to fix these much less important cases, and so I've decided to just not support them at all. There's now an explicit check to make sure no one tries to useCapturedCallable
with those sorts of functions (very unlikely they'd want to do so anyway).Tests have been updated to be much more thorough so that we now test every case on all 3 sorts of valid function
positional_or_keyword_function, keyword_only_function, var_keyword_function
.Thanks to @maxschulz-COL for spotting the bug and for his initial fix which is the basis for this!
Checklist
Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))
(if applicable)Types of changes
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":