jupyter / jupyter/nbformat

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

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

Description

```python
# nbformat.validator.py:360
# Generate cell ids if any are missing
if repair_duplicate_cell_ids:
cell["id"] = generate_corpus_id()
changes += 1
```

Where

```python
# 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:
```python
cell["id"] = generate_corpus_id()
```

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

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

Contributor guide

Open the contributing guide

Research direction

Start in nbformat.validator.py around line 360 and inspect how the cell value reaches the cell["id"] assignment. Read nbformat.corpus.words to confirm the generated ID type, then reproduce the reported validation path. Done means the reported input no longer raises the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.