Skip to content

[pycocotools] Accept lists of RLEs in mask.decode, area and toBbox - #16577

Merged
srittau merged 1 commit into
python:mainfrom
Blacksujit:pycocotools-mask-rle-lists
Oct 20, 2026
Merged

srittau merged 1 commit into
python:mainfrom
Blacksujit:pycocotools-mask-rle-lists

Conversation

@Blacksujit

Copy link
Copy Markdown
Contributor

pycocotools.mask.decode, area and toBbox were typed to take a single encoded RLE, but each also accepts a list of RLEs (the batch form returned by frPyObjects and used for multi-instance masks), so those calls were rejected.

This widens the three parameters to _EncodedRLE | list[_EncodedRLE], with an overload on area because it returns an array of areas for a list and a single uint32 otherwise.

Upstream source (pycocotools 2.0.11): https://github.com/ppwwyyxx/cocoapi/blob/ac87f5077ad6b8864c2dc5e93d14cae62d1db05a/PythonAPI/pycocotools/mask.py#L87-L103

AI agent used: Claude Code (claude-opus-5-5).

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

@srittau
srittau merged commit 4c6a006 into python:main Oct 20, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants