-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Somehow the new Marimo Notebooks which are .py
files rather than .ipynb
(the extension used by Jupyter) are failing
linting with ruff and
numpydoc-validation during Pre-commit checks (see failed
log)
Ruff
NB - The first three issues of invalid # ruff: noqa
are not Notebooks, they are in topostats/filter.py
and @ns-rse
will fix those shortly.
ruff (legacy alias)......................................................Failed
- hook id: ruff
- exit code: 1
warning: Invalid `# ruff: noqa` directive at topostats/filters.py:9: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# ruff: noqa` directive at topostats/filters.py:19: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# ruff: noqa` directive at topostats/filters.py:20: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
D100 Missing docstring in public module
--> notebooks/contributing_to_topostats.py:1:1
D100 Missing docstring in public module
--> notebooks/grainstats.py:1:1
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/grainstats.py:459:5
|
457 | plotting_config["cmap"] = current_cmap
458 | plotting_config["zrange"] = current_zrange
459 | fig
| ^^^
460 | return
|
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/grainstats.py:510:5
|
508 | @app.cell
509 | def _(grains):
510 | grains.__dict__
| ^^^^^^^^^^^^^^^
511 | return
|
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/grainstats.py:535:5
|
534 | # Return both so they render one after the other
535 | binary_mask, mask_overlay
| ^^^^^^^^^^^^^^^^^^^^^^^^^
536 | return
|
W291 Trailing whitespace
--> notebooks/grainstats.py:549:183
|
547 | …
548 | …
549 | …, it is printed below to show which parameters can be configured.
| ^
550 | …
551 | …lecular
|
help: Remove trailing whitespace
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/grainstats.py:613:5
|
611 | )
612 |
613 | original_threshold, new_threshold
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
614 | return
|
D100 Missing docstring in public module
--> notebooks/tracestats.py:1:1
F841 Local variable `loading_config` is assigned to but never used
--> notebooks/tracestats.py:126:5
|
125 | config = read_yaml(BASE_DIR.parent / "topostats" / "default_config.yaml")
126 | loading_config = config["loading"]
| ^^^^^^^^^^^^^^
127 | filter_config = config["filter"]
128 | filter_config["remove_scars"]["run"] = True
|
help: Remove assignment to unused variable `loading_config`
F841 Local variable `img` is assigned to but never used
--> notebooks/tracestats.py:148:5
|
146 | all_scan_data = LoadScans(image_files, **config["loading"])
147 | all_scan_data.get_data()
148 | img = all_scan_data.img_dict["plasmids"]["image_original"]
| ^^^
149 |
150 | filter_config["remove_scars"]["run"] = True
|
help: Remove assignment to unused variable `img`
F841 Local variable `mask` is assigned to but never used
--> notebooks/tracestats.py:178:5
|
176 | grains.find_grains()
177 |
178 | mask = grains.mask_images["above"]["merged_classes"][:, :, 1].astype(bool)
| ^^^^
179 | image = grains.image
|
help: Remove assignment to unused variable `mask`
F841 Local variable `labelled_regions` is assigned to but never used
--> notebooks/tracestats.py:181:5
|
179 | image = grains.image
180 |
181 | labelled_regions = Grains.label_regions(
| ^^^^^^^^^^^^^^^^
182 | grains.mask_images["above"]["merged_classes"][:, :, 1].astype(bool).astype(int)
183 | )
|
help: Remove assignment to unused variable `labelled_regions`
F841 Local variable `grain_stats` is assigned to but never used
--> notebooks/tracestats.py:196:5
|
195 | _temp = grainstats.calculate_stats()
196 | grain_stats = {"statistics": _temp[0], "plots": _temp[1]}
| ^^^^^^^^^^^
197 | return (
198 | curvature_config,
|
help: Remove assignment to unused variable `grain_stats`
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/tracestats.py:228:5
|
227 | # Return both so they render one after the other
228 | filtered_image_plot, grains_mask_plot
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229 | return
|
W291 Trailing whitespace
--> notebooks/tracestats.py:278:281
|
276 | …
277 | …
278 | …` and `grain_1` - the two grains that we saw in our masked image.
| ^
279 | …
280 | …g additional processing, known as pruning, to remove spurious branches.
|
help: Remove trailing whitespace
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/tracestats.py:327:5
|
325 | )
326 |
327 | grain0_prunedskel, grain1_prunedskel
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
328 | return
|
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/tracestats.py:407:5
|
405 | connected_nodes = show_image(image_dict["connected_nodes"], cmap="gray", colorbar=False, title="Connected nodes")
406 |
407 | original_nodes, connected_nodes
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
408 | return
|
B018 Found useless expression. Either assign it to a variable or remove it.
--> notebooks/tracestats.py:658:5
|
656 | )
657 |
658 | fig1
| ^^^^
659 | return
|
Found 18 errors.
No fixes available (7 hidden fixes can be enabled with the `--unsafe-fixes` option).
Numpydoc validatio
numpydoc-validation......................................................Failed
- hook id: numpydoc-validation
- exit code: 1
notebooks/contributing_to_topostats.py:1: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:8: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:19: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:45: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:51: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:60: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:68: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:74: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:82: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:83: PR01 Parameters {'colorbar', 'title', 'arr', 'cmap', 'size'} not documented
notebooks/contributing_to_topostats.py:102: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:114: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:132: GL08 The object does not have a docstring
notebooks/contributing_to_topostats.py:140: GL08 The object does not have a docstring
notebooks/tracestats.py:1: GL08 The object does not have a docstring
notebooks/tracestats.py:8: GL08 The object does not have a docstring
notebooks/tracestats.py:25: GL08 The object does not have a docstring
notebooks/tracestats.py:78: GL08 The object does not have a docst
(output truncated)
As these are public facing material that people will use and learn from we should ensure that we adhere to good
practices, and follow PEP8 in our coding style, i.e. fix the issues highlighted by Ruff).
I'm less concerned about the Numpydoc validation failures here as many of these look to be artefacts of the way in which
Markdown is interweaved with code chunks in Marimo so I'd suggest excluding them from being checked
by the pre-commit hook. @ns-rse will address this when correcting the incorrect notation of ruff ignores in
topostats/filters.py
shortly.