From c93882e8b2c11ff655b5653b101167eb9d344ede Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 19 Jan 2026 18:35:13 -0800 Subject: [PATCH] [Polygon.rect] raise a PatternError when given the wrong number of args instead of assert --- masque/shapes/polygon.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/masque/shapes/polygon.py b/masque/shapes/polygon.py index fc17f61..c8c3ddd 100644 --- a/masque/shapes/polygon.py +++ b/masque/shapes/polygon.py @@ -256,6 +256,11 @@ class Polygon(Shape): Returns: A Polygon object containing the requested rectangle """ + if sum(int(pp is None) for pp in (xmin, xmax, xctr, lx)) != 2: + raise PatternError('Exactly two of xmin, xctr, xmax, lx must be provided!') + if sum(int(pp is None) for pp in (ymin, ymax, yctr, ly)) != 2: + raise PatternError('Exactly two of ymin, yctr, ymax, ly must be provided!') + if lx is None: if xctr is None: assert xmin is not None