Skip to content

Commit

Permalink
fix(decl): Don't constrain !new_object type hints any more
Browse files Browse the repository at this point in the history
The `len() == 1` constraint was introduced during v0.5.x days, when
`NewObject` actually allowed more than one type hint. Now that the type
hint is a single string instead of a list of strings, this constraint
needs to be lifted.
  • Loading branch information
Wuestengecko committed Aug 12, 2024
1 parent ba1b501 commit cb8c62d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions capellambse/decl.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,8 @@ def represent_uuidref(self, data: t.Any) -> yaml.Node:
def represent_newobj(self, data: t.Any) -> yaml.Node:
assert isinstance(data, NewObject)
attrs = dict(data._kw)
if len(data._type_hint) > 1:
raise TypeError("Cannot use more than one type hint")
if len(data._type_hint) == 1:
attrs["_type"] = data._type_hint[0]
if data._type_hint:
attrs["_type"] = data._type_hint
return self.represent_mapping("!new_object", attrs)

def represent_findby(self, data: t.Any) -> yaml.Node:
Expand Down

0 comments on commit cb8c62d

Please sign in to comment.