From 6023027d4769d7a14511d32cb0f46458e887e8e3 Mon Sep 17 00:00:00 2001 From: Devon R Date: Wed, 6 Mar 2024 07:37:04 +0900 Subject: [PATCH] 3.8 compat fixes 2 --- jishaku/features/baseclass.py | 3 +-- tests/test_executorfunc.py | 6 +++--- tests/test_repl.py | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jishaku/features/baseclass.py b/jishaku/features/baseclass.py index ab16adbb..2e24bde8 100644 --- a/jishaku/features/baseclass.py +++ b/jishaku/features/baseclass.py @@ -49,7 +49,6 @@ T = typing.TypeVar('T') P = ParamSpec('P') -Task = asyncio.Task[typing.Any] GenericFeature = typing.TypeVar('GenericFeature', bound='Feature') @@ -60,7 +59,7 @@ class CommandTask(typing.NamedTuple): index: int # type: ignore ctx: ContextA - task: typing.Optional[Task] + task: typing.Optional['asyncio.Task[typing.Any]'] class Feature(commands.Cog): diff --git a/tests/test_executorfunc.py b/tests/test_executorfunc.py index 6500013b..a2f6b5e9 100644 --- a/tests/test_executorfunc.py +++ b/tests/test_executorfunc.py @@ -33,14 +33,14 @@ def sig(*args, **kwargs): ] ) @pytest.mark.asyncio -async def test_magic_executor(args: tuple[typing.Any, ...], kwargs: dict[str, typing.Any], expected_return: tuple[int, int | None, int]): - def non_executor(a: int, b: int | None = None, *, c: int) -> tuple[int, int | None, int]: +async def test_magic_executor(args: typing.Tuple[typing.Any, ...], kwargs: typing.Dict[str, typing.Any], expected_return: typing.Tuple[int, typing.Optional[int], int]): + def non_executor(a: int, b: typing.Optional[int] = None, *, c: int) -> typing.Tuple[int, typing.Optional[int], int]: return a, b, c exact_executor = executor_function(non_executor) @executor_function - def redefined_executor(a: int, b: int | None = None, *, c: int) -> tuple[int, int | None, int]: + def redefined_executor(a: int, b: typing.Optional[int] = None, *, c: int) -> typing.Tuple[int, typing.Optional[int], int]: return a, b, c assert inspect.signature(non_executor) == inspect.signature(exact_executor) diff --git a/tests/test_repl.py b/tests/test_repl.py index 00991e31..eb49eaa2 100644 --- a/tests/test_repl.py +++ b/tests/test_repl.py @@ -11,6 +11,7 @@ import inspect import random +import typing import pytest @@ -66,7 +67,7 @@ def test_scope_var(): ] ) @pytest.mark.asyncio -async def test_executor_basic(code: str, expected: list[int]): +async def test_executor_basic(code: str, expected: typing.List[int]): return_data: list[int] = [] async for result in AsyncCodeExecutor(code): return_data.append(result) @@ -100,7 +101,7 @@ async def test_executor_basic(code: str, expected: list[int]): ] ) @pytest.mark.asyncio -async def test_executor_advanced(code: str, expected: list[int | None], arg_dict: dict[str, int] | None, scope: Scope): +async def test_executor_advanced(code: str, expected: typing.List[typing.Optional[int]], arg_dict: typing.Optional[typing.Dict[str, int]], scope: Scope): return_data: list[int | None] = [] async for result in AsyncCodeExecutor(code, scope, arg_dict=arg_dict):