Add immutable Monitor model - #566
Conversation
Replace monitor dictionaries with a frozen, slotted Monitor dataclass while preserving temporary string-key access. Update platform enumeration, legacy grab inputs, filename formatting, typing, tests, examples, and migration documentation.
Some samples would not work correctly. Also prepared for eventually phasing out string like access.
jholveck
left a comment
There was a problem hiding this comment.
I'm not really comfortable with this idea of making synthetic Monitor objects to send down through _impl.grab, rather than sending capture regions as dicts or tuples. Can you elaborate on why you made that choice?
- MSS.grab() still accepts Monitor, dictionaries, and tuples, but normalizes them to CaptureRegion. - Platform backends and custom screenshot classes now receive regions, never synthetic monitors. - Added Monitor.as_capture_region(). - Applied the Linux **output_ids and comment cleanups. - Fixed the demo import grouping. - Documented why monitors are immutable. - Added test_wheel guidance to AGENTS.md.
|
One overall thing. I'm wondering if the name |
Yeah, I think that (Besides, Food for thought: should a |
Changes proposed in this PR
Fixes #470
Replace heterogeneous monitor dictionaries with a frozen, slotted
Monitordataclass that exposes typed geometry andplatform metadata attributes.
Monitorobjects.grab().regions.
test_sdistwhen files are added, removed, or renamed.This gives callers a stable, read-only monitor representation without preventing existing applications from passing
dictionary-based capture regions.
./check.shpassedValidation:
uv run ./check.sh. The full pytest suite was not run during the final review.AI assistance disclosure
Codex assisted with reviewing the implementation, identifying and implementing follow-up fixes in the demos and
ScreenShotinitialization, updating the immutability test for static typing, running validation, and drafting this PRdescription. The contributor reviewed and directed the API and capture-region decisions.