From 9d5177ce6380ca48fd318f62851d7c3d4107d10a Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 12 Oct 2023 01:31:05 -0700 Subject: [PATCH] Allow Pattern.ref() to take an Abstract --- masque/pattern.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/masque/pattern.py b/masque/pattern.py index 7efa72e..d5aca46 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -681,7 +681,7 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): """ return bool(self.ports) - def ref(self, target: str | None, *args: Any, **kwargs: Any) -> Self: + def ref(self, target: str | Abstract | None, *args: Any, **kwargs: Any) -> Self: """ Convenience function which constructs a `Ref` object and adds it to this pattern. @@ -694,6 +694,8 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): Returns: self """ + if isinstance(target, Abstract): + target = target.name self.refs[target].append(Ref(*args, **kwargs)) return self