jupyter / jupyter/nbformat

Ambiguous warning about missing cell IDs

Open
#359 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
313
Forks
176
PR merge metrics
No merged PRs in 30d

Description

#282 refactored normalisation of missing cell IDs, removing lines:

```python
notebook_supports_cell_ids = ref is None and version >= 4 and version_minor >= 5
if notebook_supports_cell_ids and repair_duplicate_cell_ids:
# Auto-generate cell ids for cells that are missing them.
for cell in nbdict["cells"]:
if "id" not in cell:
# Generate cell ids if any are missing
cell["id"] = generate_corpus_id()
```

and replacing them with:

```python
if (version, version_minor) >= (4, 5):
# if we support cell ids ensure default ids are provided
for cell in nbdict["cells"]:
if "id" not in cell:
warnings.warn(
"Code cell is missing an id field, this will become"
" a hard error in future nbformat versions. You may want"
" to use `normalize()` on your notebooks before validations"
" (available since nbformat 5.1.4). Previous versions of nbformat"
" are fixing this issue transparently, and will stop doing so"
" in the future.",
MissingIDFieldWarning,
stacklevel=3,
)
# Generate cell ids if any are missing
if repair_duplicate_cell_ids:
cell["id"] = generate_corpus_id()
changes += 1
```

However,
- during validation `repair_duplicate_cell_ids` is set to `False`, and in general I do not understand why it is reusing `repair_duplicate_cell_ids` - was it meant to be a new variable for missing cell IDs?
- `Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future` - this sentence is ambiguous; does it mean that current version still fixes this issue transparently or not?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.