titus.util.untagUnion

titus.util.untagUnion(expr, unionTypes)[source]

Turn a tagged union datum into a bare Python object or pass-through if not a tagged union datum.

Parameters:
  • expr (anything) – tagged union, which may be of the form {"tag": value} or just value
  • unionTypes (list of Pythonized JSON) – types allowed by this union in Pythonized JSON schemas
Return type:

anything

Returns:

{"tag": value} collapsed to value if tag names one of the unionTypes; otherwise, pass-through