From 468322ceb9002aa1fcdf282f1353a2df7e3410e9 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 17 Jul 2023 21:29:12 -0700 Subject: [PATCH] add has_ports() --- masque/pattern.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/masque/pattern.py b/masque/pattern.py index c8c2c30..c80284c 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -593,7 +593,6 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): def is_empty(self) -> bool: """ - # TODO is_empty doesn't include ports... maybe there should be an equivalent? Returns: True if the pattern is contains no shapes, labels, or refs. """ @@ -620,6 +619,13 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): """ return any(True for _ in chain.from_iterable(self.labels.values())) + def has_ports(self) -> bool: + """ + Returns: + True if the pattern contains any ports. + """ + return bool(self.ports) + def ref(self, target: str | None, *args: Any, **kwargs: Any) -> Self: """ Convenience function which constructs a `Ref` object and adds it