From bf64a1db729c131f2393d8216bfe779af8bf79a8 Mon Sep 17 00:00:00 2001 From: monosans Date: Tue, 9 Jul 2024 03:35:52 +0300 Subject: [PATCH] Don't create TypeVars at runtime --- nitro_generator_checker/__main__.py | 13 ++++++------- nitro_generator_checker/utils.py | 7 +++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/nitro_generator_checker/__main__.py b/nitro_generator_checker/__main__.py index b0cb74f..b003fb6 100644 --- a/nitro_generator_checker/__main__.py +++ b/nitro_generator_checker/__main__.py @@ -10,17 +10,11 @@ from aiohttp import ClientSession, DummyCookieJar, TCPConnector from rich.console import Console from rich.logging import RichHandler -from typing_extensions import TypeVar from . import http from .nitro_checker import NitroChecker from .utils import bytes_decode -if TYPE_CHECKING: - from typing import Callable, Coroutine - - from typing_extensions import Any - if sys.version_info >= (3, 11): try: import tomllib @@ -31,7 +25,12 @@ else: import tomli as tomllib -T = TypeVar("T") +if TYPE_CHECKING: + from typing import Callable, Coroutine + + from typing_extensions import Any, TypeVar + + T = TypeVar("T") def get_async_run() -> Callable[[Coroutine[Any, Any, T]], T]: diff --git a/nitro_generator_checker/utils.py b/nitro_generator_checker/utils.py index e2171fb..e949f2a 100644 --- a/nitro_generator_checker/utils.py +++ b/nitro_generator_checker/utils.py @@ -5,15 +5,14 @@ from typing import TYPE_CHECKING import charset_normalizer -from typing_extensions import ParamSpec, TypeVar if TYPE_CHECKING: from typing import Callable, Coroutine - from typing_extensions import Any + from typing_extensions import Any, ParamSpec, TypeVar -T = TypeVar("T") -P = ParamSpec("P") + T = TypeVar("T") + P = ParamSpec("P") background_tasks: set[asyncio.Task[Any]] = set()