-
Notifications
You must be signed in to change notification settings - Fork 47
Add pass through kopts dict for kaleido args #316
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
src/py/kaleido/__init__.py
Outdated
|
||
""" | ||
async with Kaleido(n=n) as k: | ||
if "n" not in kopts: |
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.
Are you wanting to keep the separate n
argument for backwards compatibility? Or could it be removed?
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 would argue for removing it just to avoid confusion (since it's not obvious which way of passing n
takes precedence)
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.
yeah i mean, i know technically we're in a release candidate but i didn't want to change the API
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 think it's fine to remove it TBH but if not, maybe add a DeprecationWarning so it can be removed in a future release?
|
||
See documentation for `Kaleido.write_fig()`. | ||
|
||
See documentation for `Kaleido.write_fig()` for the other arguments. | ||
|
||
""" |
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.
You'll need to do a kopts = kopts or {}
here, right? Otherwise the dict operations will fail if kopts
is None
.
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.
yeah
In [2]: foo(**None)
─────────────────────────────────────────
TypeError Traceback (most recent call last)
Cell In[2], line 1
────▶ 1 foo(**None)
TypeError: __main__.foo() argument after ** must be a mapping, not NoneType
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.
Should add kopts
argument to calc_fig
as well for consistency
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 want to move towards using BytesIO as a return for write_image
instead of calc_fig
which is sort of hackey, but added the kopts
option anyway
|
||
See documentation for `Kaleido.calc_fig()`. | ||
|
||
""" | ||
async with Kaleido(n=1) as k: | ||
kopts = kopts or {} | ||
kopts["n"] = 1 |
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.
don't override user-provided value for n
kopts["n"] = 1 | |
if "n" not in kopts: | |
kopts["n"] = 1 |
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.
calc_figs can't iterate, so it doesn't make sense for n>1 (its mentioned in the docs, that any value of n will be overwritten to 1)
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.
Looks good to me! 🚀
No description provided.