Skip to content

Commit

Permalink
python_generator_test: Remove usage of typing_extensions
Browse files Browse the repository at this point in the history
All the used methods are available in the native typing
module since python 3.8
  • Loading branch information
DeltaEvo committed May 17, 2024
1 parent fe1935b commit 979c751
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pdl-compiler/tests/python_generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import enum
import json
import typing
import typing_extensions
import unittest
from importlib import resources

Expand Down Expand Up @@ -57,12 +56,12 @@ def create_object(typ, value):
field_type = field_types[f]
values[f] = create_object(field_type, v)
return typ(**values)
elif typing_extensions.get_origin(typ) is list:
typ = typing_extensions.get_args(typ)[0]
elif typing.get_origin(typ) is list:
typ = typing.get_args(typ)[0]
return [create_object(typ, v) for v in value]
elif typing_extensions.get_origin(typ) is typing.Union:
elif typing.get_origin(typ) is typing.Union:
# typing.Optional[int] expands to typing.Union[int, None]
typ = typing_extensions.get_args(typ)[0]
typ = typing.get_args(typ)[0]
return create_object(typ, value) if value is not None else None
elif typ is bytes:
return bytes(value)
Expand Down

0 comments on commit 979c751

Please sign in to comment.