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

Fix false “undefined name” message caused by cell magic #1007

Merged
merged 7 commits into from Nov 25, 2023

Conversation

i-aki-y
Copy link
Contributor

@i-aki-y i-aki-y commented Nov 4, 2023

References

In this PR, I want to fix #635.

Code changes

According to the comment in #635, I implemented another transformation to the specific cell magics.

From:

%%capture --no-display
x = 1

To:

# START_CELL_MAGIC("capture", "--no-display")
x = 1
# END_CELL_MAGIC

Instead of:

get_ipython().run_cell_magic("capture", "--no-display", """x=1""")

Currently, the target cell magics are hard coded (%%time, %%capture).
It would be better if the list is configurable.
Since I'm new to the project, I need more time to figure out how to make the list configurable, but I will try this in the near future.

User-facing changes

As pointed out in #635, variables defined inside cell magics are not recognized by the lsp, and undefined name message shows up.
This PR tries to remove these false messages.

Backwards-incompatible changes

No

Chores

  • linted
  • tested
  • documented
  • changelog entry

Copy link

github-actions bot commented Nov 4, 2023

Binder 👈 Launch a binder notebook on branch i-aki-y/jupyterlab-lsp/fix-cell-magic-scope

@krassowski krassowski added the bug Something isn't working label Nov 4, 2023
Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @i-aki-y for the PR (and patience)

@krassowski krassowski merged commit 82bf833 into jupyter-lsp:main Nov 25, 2023
16 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support %%time
2 participants