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:
Thomas
2025-07-08 16:41:09 +02:00
committed by GitHub
parent 8dbe84fd1c
commit 9c598eeacc
19 changed files with 63 additions and 51 deletions

View File

@@ -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)

View File

@@ -1,6 +1,6 @@
from jambo.parser import ArrayTypeParser
from typing_extensions import get_args
from typing import get_args
from unittest import TestCase

View File

@@ -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