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

isort doesn't format the imports in PyCharm's Jupyter notebooks #2254

Open
artyommatveev opened this issue Apr 3, 2024 · 0 comments
Open

Comments

@artyommatveev
Copy link

artyommatveev commented Apr 3, 2024

Hi! I've just created an External Tool instance for isort in PyCharm Professional and checked whether it works or not. Here's a screenshot of my tool's settings.
Screenshot_1

It turned out that it works smoothly with regular .py scripts, but it doesn't work with .ipynb files (Jupyter notebooks) at all. It might be worth noting that I've also been using the black formatter (see the settings in the screenshot below) together with isort and it works without any problems in .py files.
Screenshot_2

However, when I run isort in a notebook, it doesn't format imports in the notebook's cells; I just receive the following output:

C:\Users\USERNAME\AppData\Local\Programs\Python\Python310/Scripts/isort file_name.ipynb

Process finished with exit code 0

The only solution I've come across at this point is to use nbQA in the terminal as follows:
nbqa isort file_name.ipynb

In this case, it's possible to format the imports as expected. Could you tell me if it's a bug or not? Would it be better to contact JetBrains, as it might be a problem from their side?

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

No branches or pull requests

1 participant