-
Notifications
You must be signed in to change notification settings - Fork 240
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
Share some options between the CLI and magic. #350
base: main
Are you sure you want to change the base?
Conversation
See discussion in #334 |
This refactor compute_render_options, to be shared between CLI and magic. Add a few of the CLI options to be available in the magic. The only thing I don't really like is that we redefine the help text options.
Closing and reopening to trigger CI. |
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.
sorry for the delay in the review. it looks good! just a couple comments
def _compute_render_options( | ||
options: CommandLineOptions, | ||
renderer_class: type[renderers.Renderer], | ||
unicode_support: bool, | ||
color_support: bool, | ||
) -> Tuple[Optional[str], Optional[dict[str, Any]]]: | ||
""" | ||
Similar as compute_render_options, but return a tuple (error message, data) | ||
if there is an error; this will let us reuse _compute_render_options in magics. | ||
|
||
output_file, has been replaced by unicode_support:bool, color_support:bool | ||
""" |
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 we don't need this extra wrapper function, rather, instead we could wrap the invocations of compute_render_options
in magic.py with try:...catch:
...? unless i'm missing something?
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 just wanted to avoid contaminating the magic system with OptionsParseError
, which is defined in __main__
, and I don't want cyclic imports; but I can make compute_render_option
not raise as it is used in a single place, and raise OptionsParseError
in the sole place it it used.
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.
Also compute_render_options
, takes an output_file
while the private variant takes two booleans (unicode_support: bool, color_support: bool)
, as there are no output file when running the magic. I can lift both of those as well
No needs to apologize, this is open source and users are not owed anything. I will look back into this when possible, Happy new year as well. |
Co-authored-by: Joe Rickerby <joerick@mac.com>
This refactor compute_render_options, to be shared between CLI and magic.
Add a few of the CLI options to be available in the magic.
The only thing I don't really like is that we redefine the help text options.