Skip to content

Commit e0ac82a

Browse files
committed
Drop ruff bugbear (B*) in notebooks repo
Bugbear flags bare expressions (B018) which are the notebook idiom for displaying values (e.g., a trailing `sdata` to render the SpatialData repr). Dropping the B family keeps the rules that catch real defects (E, F, W, I, UP) without fighting notebook conventions. Also wire `[tool.nbqa.addopts]` so notebook-specific overrides reach ruff when nbqa converts .ipynb -> .py (the per-file-ignores keyed on *.ipynb don't match the converted path). Removes the spurious blank line ruff/I removed between the two `spatialdata*` imports in getting_started.ipynb.
1 parent cdfefba commit e0ac82a

2 files changed

Lines changed: 30 additions & 23 deletions

File tree

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,16 @@ line-length = 120
3939
target-version = "py311"
4040

4141
[tool.ruff.lint]
42-
select = ["E", "F", "W", "I", "UP", "B"]
42+
# Notebooks have different idioms than production code (bare expressions to
43+
# render values, repeated assignment to inspect state). Skip bugbear (B*) and
44+
# enforce only the rules that catch real defects.
45+
select = ["E", "F", "W", "I", "UP"]
4346
ignore = ["E501"] # long lines fine in notebooks
4447

4548
[tool.ruff.lint.per-file-ignores]
4649
"*.ipynb" = ["E402"] # imports after markdown intro cells are common
50+
51+
# nbqa runs ruff against a converted .py file, so per-file-ignores keyed on
52+
# *.ipynb don't match. Pass notebook-specific overrides through here instead.
53+
[tool.nbqa.addopts]
54+
ruff = ["--extend-ignore=E402"]

tutorials/getting_started.ipynb

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"\n",
1010
"This tutorial walks through the core mental model of [`spatialdata-plot`](https://github.com/scverse/spatialdata-plot): a fluent API on top of a `SpatialData` object that lets you layer the four spatial element types (images, labels, shapes, points) into a single matplotlib figure.\n",
1111
"\n",
12-
"We use the lightweight built-in `blobs` dataset so this notebook runs in seconds with zero downloads. Once the API clicks, the same calls work on Visium, Xenium, MERFISH, or any other dataset that can be loaded as a `SpatialData` object see the other tutorials in this gallery for real-world examples."
12+
"We use the lightweight built-in `blobs` dataset so this notebook runs in seconds with zero downloads. Once the API clicks, the same calls work on Visium, Xenium, MERFISH, or any other dataset that can be loaded as a `SpatialData` object \u2014 see the other tutorials in this gallery for real-world examples."
1313
]
1414
},
1515
{
@@ -19,7 +19,7 @@
1919
"source": [
2020
"## The data\n",
2121
"\n",
22-
"`sd.datasets.blobs()` returns a `SpatialData` object containing one image, one label mask, one points layer, and several shape layers all aligned in the `global` coordinate system."
22+
"`sd.datasets.blobs()` returns a `SpatialData` object containing one image, one label mask, one points layer, and several shape layers \u2014 all aligned in the `global` coordinate system."
2323
]
2424
},
2525
{
@@ -39,22 +39,22 @@
3939
"data": {
4040
"text/plain": [
4141
"SpatialData object\n",
42-
"├── Images\n",
43-
" ├── 'blobs_image': DataArray[cyx] (3, 512, 512)\n",
44-
" └── 'blobs_multiscale_image': DataTree[cyx] (3, 512, 512), (3, 256, 256), (3, 128, 128)\n",
45-
"├── Labels\n",
46-
" ├── 'blobs_labels': DataArray[yx] (512, 512)\n",
47-
" └── 'blobs_multiscale_labels': DataTree[yx] (512, 512), (256, 256), (128, 128)\n",
48-
"├── Points\n",
49-
" └── 'blobs_points': DataFrame with shape: (<Delayed>, 4) (2D points)\n",
50-
"├── Shapes\n",
51-
" ├── 'blobs_circles': GeoDataFrame shape: (5, 2) (2D shapes)\n",
52-
" ├── 'blobs_multipolygons': GeoDataFrame shape: (2, 1) (2D shapes)\n",
53-
" └── 'blobs_polygons': GeoDataFrame shape: (5, 1) (2D shapes)\n",
54-
"└── Tables\n",
55-
" └── 'table': AnnData (26, 3)\n",
42+
"\u251c\u2500\u2500 Images\n",
43+
"\u2502 \u251c\u2500\u2500 'blobs_image': DataArray[cyx] (3, 512, 512)\n",
44+
"\u2502 \u2514\u2500\u2500 'blobs_multiscale_image': DataTree[cyx] (3, 512, 512), (3, 256, 256), (3, 128, 128)\n",
45+
"\u251c\u2500\u2500 Labels\n",
46+
"\u2502 \u251c\u2500\u2500 'blobs_labels': DataArray[yx] (512, 512)\n",
47+
"\u2502 \u2514\u2500\u2500 'blobs_multiscale_labels': DataTree[yx] (512, 512), (256, 256), (128, 128)\n",
48+
"\u251c\u2500\u2500 Points\n",
49+
"\u2502 \u2514\u2500\u2500 'blobs_points': DataFrame with shape: (<Delayed>, 4) (2D points)\n",
50+
"\u251c\u2500\u2500 Shapes\n",
51+
"\u2502 \u251c\u2500\u2500 'blobs_circles': GeoDataFrame shape: (5, 2) (2D shapes)\n",
52+
"\u2502 \u251c\u2500\u2500 'blobs_multipolygons': GeoDataFrame shape: (2, 1) (2D shapes)\n",
53+
"\u2502 \u2514\u2500\u2500 'blobs_polygons': GeoDataFrame shape: (5, 1) (2D shapes)\n",
54+
"\u2514\u2500\u2500 Tables\n",
55+
" \u2514\u2500\u2500 'table': AnnData (26, 3)\n",
5656
"with coordinate systems:\n",
57-
" 'global', with elements:\n",
57+
" \u25b8 'global', with elements:\n",
5858
" blobs_image (Images), blobs_multiscale_image (Images), blobs_labels (Labels), blobs_multiscale_labels (Labels), blobs_points (Points), blobs_circles (Shapes), blobs_multipolygons (Shapes), blobs_polygons (Shapes)"
5959
]
6060
},
@@ -65,7 +65,6 @@
6565
],
6666
"source": [
6767
"import spatialdata as sd\n",
68-
"\n",
6968
"import spatialdata_plot # noqa: F401 (registers the .pl accessor)\n",
7069
"\n",
7170
"sdata = sd.datasets.blobs()\n",
@@ -131,7 +130,7 @@
131130
"source": [
132131
"### Render labels\n",
133132
"\n",
134-
"By default, labels are filled. Use `contour_px` to draw boundaries instead useful for overlaying segmentations on top of an image without hiding pixel-level detail."
133+
"By default, labels are filled. Use `contour_px` to draw boundaries instead \u2014 useful for overlaying segmentations on top of an image without hiding pixel-level detail."
135134
]
136135
},
137136
{
@@ -341,9 +340,9 @@
341340
"source": [
342341
"## Where to next\n",
343342
"\n",
344-
"- **API reference** every parameter for every `render_*` is documented in the [plotting API](https://spatialdata.scverse.org/projects/plot/en/latest/api.html).\n",
345-
"- **Real-data tutorials** see the other notebooks in this gallery for Visium, Xenium, and MERFISH examples that combine these primitives into complete analyses.\n",
346-
"- **Contributing** found a missing example? Open a PR on [`spatialdata-plot-notebooks`](https://github.com/scverse/spatialdata-plot-notebooks)."
343+
"- **API reference** \u2014 every parameter for every `render_*` is documented in the [plotting API](https://spatialdata.scverse.org/projects/plot/en/latest/api.html).\n",
344+
"- **Real-data tutorials** \u2014 see the other notebooks in this gallery for Visium, Xenium, and MERFISH examples that combine these primitives into complete analyses.\n",
345+
"- **Contributing** \u2014 found a missing example? Open a PR on [`spatialdata-plot-notebooks`](https://github.com/scverse/spatialdata-plot-notebooks)."
347346
]
348347
}
349348
],

0 commit comments

Comments
 (0)