add has_ports()

This commit is contained in:
Jan Petykiewicz 2023-07-17 21:29:12 -07:00
parent ece7b36801
commit a8686a6748

View File

@ -593,7 +593,6 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
def is_empty(self) -> bool: def is_empty(self) -> bool:
""" """
# TODO is_empty doesn't include ports... maybe there should be an equivalent?
Returns: Returns:
True if the pattern is contains no shapes, labels, or refs. 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())) 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: def ref(self, target: str | None, *args: Any, **kwargs: Any) -> Self:
""" """
Convenience function which constructs a `Ref` object and adds it Convenience function which constructs a `Ref` object and adds it