microsoft / microsoft/pyright

OOM on numpy in dict with an update

Open
#11,252 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

**Describe the bug**

I can get pyright 1.1.408 to OOM on a small (kind of weird) code snippet.

**Code or Screenshots**

Claude Code helped me bisect and minimize this reproducer.

With `uv` installed:

```
#!/bin/bash
set -e
REPRO_DIR=$(mktemp -d)
cd "$REPRO_DIR"

cat >pyright_oom.py <<'EOF'
def trigger_oom() -> dict:
import numpy as np
result = {"np": np}
result.update({
"str": str, "int": int, "float": float, "bool": bool,
"list": list, "dict": dict, "set": set, "tuple": tuple,
"frozenset": frozenset, "bytes": bytes, "bytearray": bytearray,
"abs": abs, "round": round, "min": min, "max": max,
"sum": sum, "pow": pow, "divmod": divmod, "len": len,
"range": range, "enumerate": enumerate, "zip": zip,
"sorted": sorted, "reversed": reversed, "slice": slice,
"map": map, "filter": filter, "any": any, "all": all, "type": type,
})
return result
EOF

cat >pyrightconfig.json <<'EOF'
{"venvPath": ".", "venv": ".venv", "pythonVersion": "3.12"}
EOF

uv venv .venv
uv pip install numpy --quiet
echo "Running pyright in $REPRO_DIR (will OOM after ~60-90s)..."
time uvx pyright pyright_oom.py
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproducer in pyright_oom.py with the pyrightconfig.json configuration and the listed uv commands. Trace the analysis triggered by the NumPy import and dictionary update, then verify that the same command completes without exhausting memory.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.