question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IPython magic commands need to be runnable from comments so other tools can work with them.

See original GitHub issue

Including magic commands in an interactive python file breaks automatic code formatting. For instance, this

#%%
%load_ext autoreload
%autoreload 2

#%%
a,b,c = [1 , 2 , 3]

will only be formatted to

#%%
# %load_ext autoreload
# %autoreload 2

#%%
a, b, c = [1, 2, 3]

if the magic commands are commented out. It would be nice if magic commands didn’t throw off the formatter, at least if the file contains #%% cell delimiters.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, Jul 8, 2019

Are you suggesting this? #! - shell assignment #!% - line magic #!%% - cell magic

I think that would work. At least I can’t think of a better idea.

1reaction
rchiodocommented, Jul 3, 2019

So are you asking for a new feature - run magics in comments?

Read more comments on GitHub >

github_iconTop Results From Across the Web

IPython magic commands need to be runnable from ... - GitHub
IPython magic commands need to be runnable from comments so other tools can work with them. Issue #3263 · microsoft/vscode-jupyter · GitHub.
Read more >
Built-in magic commands — IPython 8.7.0 documentation
To work properly, Magics must use a syntax element which is not valid in the underlying language.
Read more >
Useful IPython magic commands - Towards Data Science
In this post, we will get familiar with a few useful magic commands that you could use in Jupyter Notebook.
Read more >
Introducing IPython — IPython 3.2.1 documentation
The %run magic command allows you to run any python script and load all of its data directly into the interactive namespace. Since...
Read more >
Top 12 Magic Commands in Jupyter - Medium
Jupyter notebook has been the de-facto environment for developing all ... is also the magic command but can run on multiple lines in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found