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.

Can autoreload magics be kept above isort output?

See original GitHub issue

I have tried to look around, but I am not sure if one of the recent fixed addresses this problem. I am using nbQA for its isort functionality and have the following problem.

A notebook which looks like this (MWE)

%load_ext autoreload
%autoreload 2

import sys
import pathlib

is converted by nbqa isort into

import pathlib
import sys

%load_ext autoreload
%autoreload 2

which actually invalidates the autoreload extension that must be loaded before any imports. I have tried to use # isort:skip or put it in a different cell, but to no avail. Do you know if there’s a fix for this?

Otherwise, thanks for the great hooks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:33 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
girip11commented, Nov 25, 2020

If your isort config is present in setup.cfg, then create a different file called my_isort.cfg and pass it via the - -nbqa-config flag

1reaction
Alexander-Serovcommented, Nov 25, 2020

Btw, I have found another workaround: I can put the jupyter magic in the startup script of jupyter thus removing it from the nb. It will apply to all notebooks, but for me it is the desired behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration options for isort
Tells isort to set the known standard library based on the specified Python version. Default is to assume any Python 3 version could...
Read more >
autoreload — IPython 8.7.0 documentation
autoreload reloads modules automatically before entering the execution of code typed at the IPython prompt. ... The following magic commands are provided:.
Read more >
IPython's magic functions — Mastering JupyterLab
So whether Magics are available is a decision that is made by the kernel developer on a per-kernel basis.
Read more >
jurigged - PyPI
jurigged. Jurigged lets you update your code while it runs. Using it is trivial: jurigged your_script.py; Change some function or method with your...
Read more >
CSCI 503/490 – Assignment 5
You will be doing your work in Python for this assignment. ... To test your code, you may use the %run magic command...
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