Skip to content

fix: refuse a wildcard in Image.Read with its own error - #226

Merged
petercorke merged 2 commits into
mainfrom
bug/read-wildcard
Nov 22, 2026
Merged

petercorke merged 2 commits into
mainfrom
bug/read-wildcard

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Image.Read("dir/*.png") with a wildcard that matches files failed with a bare AssertionError. iread() returns (list of images, list of paths) for a wildcard, and Image.Read() took that tuple for a single image, so it hit its assert isinstance(image_arr, np.ndarray) and never reached its own ValueError("wildcard read not supported, use FileCollection instead"). It now checks for the list first and raises that error, which tells the user what to do instead.

Found by the new Image.Read tests (PR 222), which recorded it as a strict xfail test. That test is now an ordinary test.

Testing

tests/test_image_io_extra.py and tests/test_image_io.py: 67 passed, and 2 xfail that belong to a separate bug (the stdisp cursor, in its own PR). mypy reports no issues. The test reads tests/data/stripes*.png, which matches two real files, and expects the ValueError. Not run: CI on Windows or OpenCV 4 (CI will).

This change was written with AI assistance (Claude Code) and the diff has been read by the maintainer.

🤖 Generated with Claude Code

iread() returns (list of images, list of paths) for a wildcard, which
Image.Read() took for a single image, so it failed an assert with a bare
AssertionError and never reached its "wildcard read not supported" error. It
now checks for the list and raises that ValueError.

The xfail test that recorded the bug is now an ordinary test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit a90deaa into main Nov 22, 2026
32 checks passed
@petercorke
petercorke deleted the bug/read-wildcard branch November 22, 2026 11:43
@github-actions github-actions Bot mentioned this pull request Nov 22, 2026
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.

1 participant