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.

ENH try parsing code after cell magic, ignore if can't

See original GitHub issue

I haven’t (yet) got to the root of the issue, but the notebook in question is

https://github.com/microsoft/computervision-recipes/blob/1bb489af757fde7c773e16fab87b24305cff4457/scenarios/detection/20_deployment_on_kubernetes.ipynb


I get

$ nbqa black scenarios/detection/20_deployment_on_kubernetes.ipynb
error: cannot format scenarios/detection/20_deployment_on_kubernetes.ipynb: Cannot parse: 50:1: [print(f) for f in Path(data_path()/"odFridgeObjects"/"models").glob('**/*')]
Oh no! 💥 💔 💥
1 file failed to reformat.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
MarcoGorellicommented, Oct 20, 2020

We could do, but then there are cases when cells with cell magics contain valid code, e.g. %%time. Maybe we could do something similar to your idea of what to do with inline magics - check if what follows is valid Python code, and if it is, keep it, else ignore it?

0reactions
MarcoGorellicommented, May 3, 2021

closing as I think the current solution of --process-cells is good enough

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inside of a notebook, magic cells should not cause an error in ...
Not having a syntax error is one thing, trying to autocomplete them is another. Does the notebook code already discard the syntax error...
Read more >
turn warning off in a cell jupyter notebook - Stack Overflow
I want to turn off these warnings in a particular cell only, so not in the rest of the ipynb-file. Does someone know...
Read more >
nbQA Documentation
3.3 Cell magics. By default, nbQA will ignore line magics (e.g. %matplotlib inline), as well as most cell magics. To process code in....
Read more >
Tim's Magic-8.2 Information Page - Open Circuit Design
This provides a way to remove contact cuts from a layout without affecting the surrounding metals, which is something that the "erase" command...
Read more >
Plotting and Programming in Python - Our Lessons
A “code cell” in a Notebook is a cell that contains software; a “text cell” is one that ... Won't even try to...
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