type_info sorted a Literal's values with a plain sorted(), which raises TypeError on mixed-type literals such as Literal[1, None] or Literal[True, "yes"] since Python 3 forbids ordering across types. The encoder/decoder already support these literals, so type_info crashing on them is a contract violation. Sort by (type name, value) so same-type ordering is unchanged and mixed-type literals are grouped deterministically, with a try/except fallback. Also widen the LiteralType.values annotation to allow mixed/None members. Adds test_bool_literal and test_mixed_literal.
Siyet
mentioned this pull request
Merged