Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[BUG] This doesn't seem to work for the %run magic command #284

Closed
jencake opened this issue Jan 26, 2023 · 1 comment
Closed

[BUG] This doesn't seem to work for the %run magic command #284

jencake opened this issue Jan 26, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jencake
Copy link

jencake commented Jan 26, 2023

For variables are defined in another notebook and imported via %run. flake8_nb still gives me the variable is undefined error.

@jencake jencake added the bug Something isn't working label Jan 26, 2023
@s-weigand
Copy link
Owner

@jencake This is a general limitation when using jupyter magic syntax that manipulates the ipython kernel state at runtime and using static linters.
The problem is that magic commands aren't regular python code, so it does not translate to the equivalent python AST that flake8 uses to lint code.
The only way to fix this would require flake8 to use a different AST parser that supports jupyter magic syntax, which I'm not aware even exists and even if I don't see flake8 changing to it.

Pretty much the same issue was opened and closed for nbQA and I have the same suggestion as @MarcoGorelli to use # noqa either as comment inline or via cell tags.

The other way to solve this would be to convert the notebook you run with %run to a python file and use regular imports.

Repository owner locked and limited conversation to collaborators Feb 3, 2023
@s-weigand s-weigand converted this issue into discussion #286 Feb 3, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants