jupyter / nbformat

Reference implementation of the Jupyter Notebook format

Home Page:http://nbformat.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dsm-72 opened this issue · comments

# 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.