-
-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Hi!
I encountered the following issue when using nbqa
with ruff check
and the rule I001
. It seems that something odd happens when imports are not defined on the same cell.
I was able to build a short example that reproduces it.
The way to reproduce it is:
nbqa 'ruff check' bug.ipynb --select=I001 --fix
Found 1 error (1 fixed, 0 remaining).
bug.ipynb
:
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0f145ef6",
"metadata": {},
"outputs": [],
"source": [
"from typing import Dict"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f145ef7",
"metadata": {},
"outputs": [],
"source": [
"print(Dict)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"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.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
The following example works flawlessly:
nbqa 'ruff check' correct.ipynb --select=I001 --fix
correct.ipynb
:
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0f145ef6",
"metadata": {},
"outputs": [],
"source": [
"from typing import Dict\n",
"\n",
"print(Dict)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"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.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Metadata
Metadata
Assignees
Labels
No labels