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.02k stars 39 forks source link

nbQA pylint failing when run with --init-hook #801

Open Praful932 opened 1 year ago

Praful932 commented 1 year ago

I'm trying to add a path via the init-hook parameter of pylint, it is working when i just use pylint but shows this error when run with nbqa

nbqa pylint notebooks/ --init-hook="import sys; sys.path.append('.')"

No such file or directory: --init-hook=import sys; sys.path.append('.')

nbqa version - 1.6.1 pylint version - 2.16.2

MarcoGorelli commented 1 year ago

thanks for the report, I'll take a look

MarcoGorelli commented 1 year ago

Looks like in here

https://github.com/nbQA-dev/nbQA/blob/1409871078a21b607ea3e64335d8faaad0142274/nbqa/cmdline.py#L170

it's mistaken for root_dirs. Don't know why.

Looks like it works if you do

nbqa pylint tests/data --init-hook "import sys; sys.path.append('.')"

though, does that work for you?