Different behaviour between `nbqa black` and `nbqa black --check`
See original GitHub issueHello,
Thanks for making this awesome tool.
I’ve been having some problems related to nbqa black --check
raising problems but nbqa black
not doing anything to change it. I’ve managed to recreate this with the following minimal example. It appears to be related to how the configuration is parsed.
.
├── notebook.ipynb
└── pyproject.toml
My project has something like the following configuration. We set the line length to be 79 for source code but are happy with longer lines inside notebooks.
# pyproject.toml
[tool.black]
line-length = 79
[tool.nbqa.addopts]
# use longer lines in notebooks
black = [
"--line-length=88",
]
notebook.ipynb
has a single cell with the following contents
result = function_name(xxxxxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
The exact contents are not so important, the important thing is that the line length is more than 79 but less than 88. Running
nbqa black notebook.ipynb
results in no changes, but running
nbqa black --check notebook.ipynb
indicates that the notebook would be reformatted.
To avoid any ambiguity, here’s the notebook JSON
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "77402ebb-99fc-4232-9f9a-d46bb0d3aa3d",
"metadata": {},
"outputs": [],
"source": [
"result = function_name(xxxxxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "nbqa",
"language": "python",
"name": "nbqa"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
@tcbegley I’ve made a new release (it’s been about a year since the first version, so I’ve finally made a 1.0.0 release 🎉), if you could try it out and let me know if this doesn’t work for you, that’d be much appreciated
As an aside,
--nbqa-mutate
is no longer necessary (it won’t error if you pass it, but it won’t do anything anymore)Thanks @MarcoGorelli! Updated our CI and it all seems to be working like a charm.