Conversation
Add MS_TYPE_BOOLLITERAL_TRUE/FALSE flags and handle PyBool_Type before PyLong_Type in typenode_collect_literal. Update decode paths (JSON, msgpack, convert) to validate against specific bool literal values. Closes #859
|
Two follow-ups pushed:
Side note: the Invalid enum value wording is misleading for Literal types in general since they are not enums. I opened #1009 to track that and submitted #1010 (based on this branch) to fix it across all Literal kinds at once. |
Include MS_TYPE_BOOLLITERAL_TRUE/FALSE in the bool check so error messages like 'Expected ``, got `int`' correctly show 'bool'.
Cover json_decode_true/false and convert_bool with Literal[True], Literal[False], mixed types, and error message assertions including the typenode_simple_repr fix.
Reopening #996 (auto-closed when fork was deleted).
Summary
Literal[True],Literal[False], andLiteral[True, False]in type definitionsMS_TYPE_BOOLLITERAL_TRUE/MS_TYPE_BOOLLITERAL_FALSEflags to distinguish bool literals from plainboolPyBool_TypebeforePyLong_Typeintypenode_collect_literal(sinceboolis a subclass ofint)inspect.pyLiteralType.valuestype annotation to includeboolCloses #859