jupyter / nbformat

Reference implementation of the Jupyter Notebook format
http://nbformat.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
259 stars 153 forks source link

TypeError: list indices must be integers or slices, not str #400

Open dsm-72 opened 4 months ago

dsm-72 commented 4 months ago
# nbformat.validator.py:360
# Generate cell ids if any are missing
if repair_duplicate_cell_ids:
    cell["id"] = generate_corpus_id()
    changes += 1

Where

# nbformat.corpus.words
"""Generate a corpus id."""
from __future__ import annotations

import uuid

def generate_corpus_id():
    """Generate a corpus id."""
    return uuid.uuid4().hex[:8]

The line:

cell["id"] = generate_corpus_id()

Yields:

TypeError: list indices must be integers or slices, not str

Which will always be a string since uuid.uuid4().hex[:8] is a string.