diff --git a/atom/meta/annotation_utils.py b/atom/meta/annotation_utils.py index 4f20c404..969cb9e4 100644 --- a/atom/meta/annotation_utils.py +++ b/atom/meta/annotation_utils.py @@ -44,6 +44,7 @@ def generate_member_from_type_or_generic( ) -> Member: """Generate a member from a type or generic alias.""" # Here we special case Literal to generate an Enum member. + types: tuple[type, ...] if get_origin(type_generic) is Literal: types = () else: diff --git a/tests/test_atom_from_annotations.py b/tests/test_atom_from_annotations.py index 6ab40336..4e3aafa6 100644 --- a/tests/test_atom_from_annotations.py +++ b/tests/test_atom_from_annotations.py @@ -303,7 +303,6 @@ class A(Atom, use_annotations=True, type_containers=depth): (dict, Dict, {1: 2}), (defaultdict, DefaultDict, defaultdict(int, {1: 2})), (Literal[1, 2, "a"], Enum, 2), - ], ) def test_annotations_with_default(annotation, member, default): diff --git a/tests/test_typing_utils.py b/tests/test_typing_utils.py index 4cd1bfb6..6d857a17 100644 --- a/tests/test_typing_utils.py +++ b/tests/test_typing_utils.py @@ -79,6 +79,7 @@ def test_reject_str_annotations(): with pytest.raises(TypeError): extract_types("int") + def test_reject_literal(): with pytest.raises(TypeError): extract_types(Literal[1])