Skip to content
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

Test of simpler way to define ast macros. #14100

Merged
merged 1 commit into from Jun 26, 2023

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented Jun 19, 2023

Provide and easier way to generate magics and pre-post hooks

This introduce a code base way of modifying the ast.
This allow to use Template strings with the two special variable names
names __code__ and __ret__ allowing to quickly write a magic, or
hooks that modify the ast.

This also introduce a %code_wrap cell magic to on the fly wrap code.
It is this easy to for example modify IPython to say time each block of
code, or retry them, or wrap them in try/except and analyse the error
message, profile...

Note that this is not new, but simply convenience function and
utilities, especially around hygiene.

@Carreau Carreau force-pushed the magic-ast-template branch 6 times, most recently from 908fdc1 to 3147b75 Compare June 20, 2023 11:43
@Carreau Carreau marked this pull request as ready for review June 20, 2023 13:00
This introduce a code base way of modifying the ast.
This allow to use Template strings with the two special variable names
names `__code__` and `__ret__` allowing to quickly write a magic, or
hooks that modify the ast.

This also introduce a `%code_wrap` cell magic to on the fly wrap code.
It is this easy to for example modify IPython to say time each block of
code, or retry them, or wrap them in try/except and analyse the error
message, profile...

Note that this is not new, but simply convenience function and
utilities, especially around hygiene.
@Carreau Carreau merged commit c3d7f16 into ipython:main Jun 26, 2023
20 of 21 checks passed
@Carreau Carreau added this to the 8.15 milestone Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant