Skip to content

Commit

Permalink
Switch to old union syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Sep 17, 2022
1 parent 5e90679 commit 9d3db6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test_gen_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ class A:
@pytest.mark.skipif(not is_py39_plus, reason="literals and annotated are 3.9+")
def test_type_names_with_quotes():
"""Types with quote characters in their reprs should work."""
from typing import Annotated, Literal
from typing import Annotated, Literal, Union

converter = Converter()

assert converter.structure({1: 1}, Dict[Annotated[int, "'"], int]) == {1: 1}

converter.register_structure_hook_func(
lambda t: t is Literal["a", 2, 3] | Literal[4], lambda v, _: v
lambda t: t is Union[Literal["a", 2, 3], Literal[4]], lambda v, _: v
)
assert converter.structure(
{2: "a"}, Dict[Literal["a", 2, 3] | Literal[4], str]
{2: "a"}, Dict[Union[Literal["a", 2, 3], Literal[4]], str]
) == {2: "a"}

0 comments on commit 9d3db6d

Please sign in to comment.