Skip to content

Commit

Permalink
chore(Python): Unknown union variants are labelled as "Unknown" (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmcdonald3 authored Aug 27, 2024
1 parent 768014f commit 317bfcb
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def __eq__(self, other: Any) -> bool:
// Since the underlying value is unknown and un-comparable, that is the only
// realistic implementation.
var unknownSymbol = symbolProvider.toSymbol(shape).expectProperty("unknown", Symbol.class);
String unknownSymbolName = unknownSymbol.getName() + "Unknown";
writer.write("""
class $1L():
\"""Represents an unknown variant.
Expand All @@ -162,8 +163,8 @@ raise TypeError(f"Unions may have exactly 1 value, but found {len(d)}")
def __repr__(self) -> str:
return f"$1L(tag={self.tag})"
""", unknownSymbol.getName());
memberNames.add(unknownSymbol.getName());
""", unknownSymbolName);
memberNames.add(unknownSymbolName);

shape.getTrait(DocumentationTrait.class).ifPresent(trait -> writer.writeComment(trait.getValue()));
writer.addStdlibImport("typing", "Union");
Expand Down

0 comments on commit 317bfcb

Please sign in to comment.