nbQA-dev / nbQA

Run ruff, isort, pyupgrade, mypy, pylint, flake8, and more on Jupyter Notebooks
https://nbqa.readthedocs.io/en/latest/index.html
MIT License
1.04k stars 41 forks source link

Support for subcommands #747

Closed MarcoGorelli closed 2 years ago

MarcoGorelli commented 2 years ago

closes #738

MarcoGorelli commented 2 years ago

@s-weigand any objections here?

MarcoGorelli commented 2 years ago

@dnoliver fancy trying this out? I think this should now work:

nbqa --nbqa-shell --nbqa-md "cspell lint" .
s-weigand commented 2 years ago

@MarcoGorelli I wanted to add an additional integration test with cspell because python tools get better discovered than external ones.

And I ran into 2 problems:

Sadly I'm currently not at home to access my windows PC and my old laptop is a bit too weak to run a VM, SO I currently can't debug it properly. Maybe you got an idea of what the problem might be since you are a lot closer to the code and test base than me ^^

Flaky CI runs:

dnoliver commented 2 years ago

@MarcoGorelli works great :)

Tested it with this repo https://github.com/openvinotoolkit/openvino_notebooks. It took me a couple of minutes to find that contributing.rst file and find the tox instructions :)

(venv) dnoliver $ nbqa --nbqa-shell 'cspell check --color' notebooks/001-hello-world/001-hello-world.ipynb

Check file: notebooks/001-hello-world/001-hello-world.ipynb

# %%NBQA-CELL-SEPae20a6
import cv2
import matplotlib.pyplot as plt
import numpy as np
from openvino.runtime import Core

# %%NBQA-CELL-SEPae20a6
ie = Core()
model = ie.read_model(model="model/v3-small_224_1.0_float.xml")
compiled_model = ie.compile_model(model=model, device_name="CPU")

output_layer = compiled_model.output(0)

You can't see it, but it is colorizing the flagged words :)

MarcoGorelli commented 2 years ago

sometimes I get an additional spelling error that isn't there when rerun

It could be because of this:

https://github.com/nbQA-dev/nbQA/blob/a73e5258f76c59a4458d8f9a7d3853078369f86d/nbqa/save_code_source.py#L28

we generate a random cell separator, and sometimes it could have some string of symbols that are detected as invalid words?


I've tried running this on Windows to check, but am getting

(base) C:\Users\User>npm install -g cspell
npm ERR! code EBUSY
npm ERR! syscall rename
npm ERR! path C:\Users\User\AppData\Local\npm-cache\_cacache\tmp\dbb8b7d8
npm ERR! dest C:\Users\User\AppData\Local\npm-cache\_cacache\content-v2\sha512\bf\29\a21c754f4203a3ddfc6808b2210b847e21bfc098ed857aebcb82726d85847d7d765845156176a3545fd710be090304d72188e59fee500dc6f8bbf8e75272
npm ERR! errno EBUSY
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/@cspell%2fcspell-pipe: EBUSY: resource busy or locked, rename 'C:\Users\User\AppData\Local\npm-cache\_cacache\tmp\dbb8b7d8' -> 'C:\Users\User\AppData\Local\npm-cache\_cacache\content-v2\sha512\bf\29\a21c754f4203a3ddfc6808b2210b847e21bfc098ed857aebcb82726d85847d7d765845156176a3545fd710be090304d72188e59fee500dc6f8bbf8e75272'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Local\npm-cache\_logs\2022-09-15T20_33_17_877Z-debug-0.log                                                                   

and can't figure out what to do about it. I've tried npm cache clear --force but it didn't help (note that on Linux I've managed to install it without issues)

MarcoGorelli commented 2 years ago

Still unable to install cspell on Windows

we generate a random cell separator, and sometimes it could have some string of symbols that are detected as invalid words?

I think this is probably not an issue, as people can use ignoreRegExpList to ignore patterns


Tempted to just ship this, if there's issues running on Windows we can always revisit later

MarcoGorelli commented 2 years ago

let's ship this for now - thanks @s-weigand and @dnoliver !