-
Notifications
You must be signed in to change notification settings - Fork 236
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
Draft: Share option definition between cli and magic. #334
base: main
Are you sure you want to change the base?
Conversation
That long term goal it to reuse this when defining the flags of the magic, though the magic is a bit different as it uses argparse.
This reverts commit f9b9441dacc5d9b4f853ff4c4604f649c25186c7.
I also want to note that pyinsturment is currently using Otparse which is marked as deprecated since 3.2 in favor of argparse. I guess there might be a reason not to use Argparse. |
I'm thinking we might want to have and explicit opt-in list instead of opt-out list, and that many of those options like load and co, only make sens with a line magic, not a cell magic. |
This makes me realize looking at options that the IPython magic in consoel should likely default to --color --unicode |
Hmm, I think I'd suggest a different approach... I think most of the options probably shouldnt be shared.
We could get a lot of milage from sharing the logic of compute_render_options. I suppose it would be nice to share some other properties of the options, but yes, unfortunately pyinstrument is still on optparse - I think the reason was that it was difficult to leave some options unparsed with argparse when I first wrote it over 10 years ago. Since pyinstrument is on optparse and ipython is subclassing argparse, I think it'd be unwise to try to make the options definitions polymorphic. |
Ok, i'l see if I can find a better way to do that, and pull some shared logic into Thanks for the feedback. |
For what it is worth I was asked to look at #324 (for cross reference). I don't have much context, but I'm guessing that For |
There is some request in #324 to have the same options (when possible) between the magic and the CLI.
I'm looking into defining those options only once, and refactoring main/magic to not repeat the options handling.
I'm tryin to be the least invasive as possible.
I'm not yet looking for deep review, but mostly letting you know I'm working on this, and maybe cursory validation that the approach is ok (or not), or wether you prefer a more thourough refactor, or simply me redefining the options twice in the
__main__
and the magic.