fix(jambo): Update legacy typing to built in types (#9)
* Migrate from `typing_extensions` to `typing` for supported Python versions, and update code to use modern type hinting with unions and annotations. * Update type hinting to use lowercase generics for Python 3.9+ compatibility.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from jambo.parser.anyof_type_parser import AnyOfTypeParser
|
||||
|
||||
from typing_extensions import Annotated, Union, get_args, get_origin
|
||||
from typing import Annotated, get_args, get_origin
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestAnyOfTypeParser(TestCase):
|
||||
)
|
||||
|
||||
# check union type has string and int
|
||||
self.assertEqual(get_origin(type_parsing), Union)
|
||||
self.assertEqual(get_origin(type_parsing), type(str | int))
|
||||
|
||||
type_1, type_2 = get_args(type_parsing)
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestAnyOfTypeParser(TestCase):
|
||||
)
|
||||
|
||||
# check union type has string and int
|
||||
self.assertEqual(get_origin(type_parsing), Union)
|
||||
self.assertEqual(get_origin(type_parsing), type(str | int))
|
||||
|
||||
type_1, type_2 = get_args(type_parsing)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from jambo.parser import ArrayTypeParser
|
||||
|
||||
from typing_extensions import get_args
|
||||
from typing import get_args
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from jambo.parser import ConstTypeParser
|
||||
|
||||
from typing_extensions import Annotated, Literal, get_args, get_origin
|
||||
from typing import Annotated, Literal, get_args, get_origin
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
Reference in New Issue
Block a user