@@ -388,9 +388,9 @@ def _make_boxes(
388388 ContentObject ,
389389 Element ,
390390 Rect ,
391- Iterable [Boxable ],
391+ Iterable [Union [ Boxable , None ] ],
392392 ],
393- ) -> Iterable [Boxable ]:
393+ ) -> Iterable [Union [ Boxable , None ] ]:
394394 """Put a box into a list of boxes if necessary."""
395395 # Is it a single Rect? (mypy is incapable of understanding the
396396 # runtime check here so we need the cast among other things)
@@ -492,7 +492,7 @@ def maker(label: str) -> PillowColor:
492492def box (
493493 objs : Union [
494494 Boxable ,
495- Iterable [Boxable ],
495+ Iterable [Union [ Boxable , None ] ],
496496 ],
497497 * ,
498498 color : Colors = DEFAULT_COLOR_CYCLE ,
@@ -514,6 +514,8 @@ def box(
514514 label_margin *= scale
515515 make_color = color_maker (color )
516516 for obj in _make_boxes (objs ):
517+ if obj is None :
518+ continue
517519 if image is None :
518520 image = _render (obj , page , dpi )
519521 try :
@@ -550,7 +552,7 @@ def box(
550552def mark (
551553 objs : Union [
552554 Boxable ,
553- Iterable [Boxable ],
555+ Iterable [Union [ Boxable , None ] ],
554556 ],
555557 * ,
556558 color : Colors = DEFAULT_COLOR_CYCLE ,
@@ -576,6 +578,8 @@ def mark(
576578 label_margin *= scale
577579 make_color = color_maker (color )
578580 for obj in _make_boxes (objs ):
581+ if obj is None :
582+ continue
579583 if image is None :
580584 image = _render (obj , page , dpi )
581585 if overlay is None :
0 commit comments