Modernize Python typing across the codebase
Automated via ruff UP006, UP007, UP035, UP045 rules (target: py311): - Replace `typing.List`, `Dict`, `Tuple`, `Set`, `FrozenSet`, `Type` with their built-in equivalents (`list`, `dict`, `tuple`, etc.) - Replace `typing.Optional[X]` with `X | None` - Replace `typing.Union[X, Y]` with `X | Y` - Move `Mapping`, `Sequence`, `Callable`, `Awaitable`, `MutableMapping`, `MutableSequence`, `Iterator`, `AsyncIterator`, `AsyncGenerator` imports from `typing` to `collections.abc` - Remove now-unused `typing` imports - Add `from __future__ import annotations` to 5 files that use forward-reference strings in `X | "Y"` annotations
This commit is contained in:
@@ -52,7 +52,7 @@ class TestDirectFunction(unittest.TestCase):
|
||||
self.assertEqual(func.properties, {})
|
||||
|
||||
async def my_function_simple_params(
|
||||
params: FunctionCallParams, name: str, age: int, height: Union[float, None]
|
||||
params: FunctionCallParams, name: str, age: int, height: float | None
|
||||
):
|
||||
return {"status": "success"}, None
|
||||
|
||||
@@ -70,7 +70,7 @@ class TestDirectFunction(unittest.TestCase):
|
||||
params: FunctionCallParams,
|
||||
address_lines: list[str],
|
||||
nickname: str | int | float,
|
||||
extra: Optional[dict[str, str]],
|
||||
extra: dict[str, str] | None,
|
||||
):
|
||||
return {"status": "success"}, None
|
||||
|
||||
@@ -134,7 +134,7 @@ class TestDirectFunction(unittest.TestCase):
|
||||
self.assertEqual(func.required, [])
|
||||
|
||||
async def my_function_simple_params(
|
||||
params: FunctionCallParams, name: str, age: int, height: Union[float, None] = None
|
||||
params: FunctionCallParams, name: str, age: int, height: float | None = None
|
||||
):
|
||||
return {"status": "success"}, None
|
||||
|
||||
@@ -143,9 +143,9 @@ class TestDirectFunction(unittest.TestCase):
|
||||
|
||||
async def my_function_complex_params(
|
||||
params: FunctionCallParams,
|
||||
address_lines: Optional[list[str]],
|
||||
address_lines: list[str] | None,
|
||||
nickname: str | int = "Bud",
|
||||
extra: Optional[dict[str, str]] = None,
|
||||
extra: dict[str, str] | None = None,
|
||||
):
|
||||
return {"status": "success"}, None
|
||||
|
||||
@@ -154,7 +154,7 @@ class TestDirectFunction(unittest.TestCase):
|
||||
|
||||
def test_property_descriptions_are_set_from_function(self):
|
||||
async def my_function(
|
||||
params: FunctionCallParams, name: str, age: int, height: Union[float, None]
|
||||
params: FunctionCallParams, name: str, age: int, height: float | None
|
||||
):
|
||||
"""
|
||||
This is a test function.
|
||||
|
||||
Reference in New Issue
Block a user