Skip to content

Commit

Permalink
Fix Literal labeling in Python 3.8 and 3.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwardrop committed Aug 15, 2024
1 parent e82beb5 commit 122ad69
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec_classes/utils/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def type_label(attr_type: Type) -> str:
method general.
"""
if hasattr(attr_type, "__origin__"): # Generics
if attr_type.__origin__ is Literal:
if str(attr_type.__origin__).replace("typing.", "") in ("Literal", "_LiteralForm"):
return f"Literal[{', '.join(repr(arg) for arg in attr_type.__args__)}]"
label = type_label(attr_type.__origin__)
if hasattr(attr_type, "__args__") and not any(
Expand Down

0 comments on commit 122ad69

Please sign in to comment.