From 06a38f8a5c51826bce07ce9b39b1f2da028e6201 Mon Sep 17 00:00:00 2001 From: Spencer Phillip Young Date: Tue, 22 Aug 2023 17:32:12 -0700 Subject: [PATCH] fix typing import for python<3.10 --- ahk/extensions.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ahk/extensions.py b/ahk/extensions.py index 7d58233..af3deec 100644 --- a/ahk/extensions.py +++ b/ahk/extensions.py @@ -1,13 +1,18 @@ from __future__ import annotations import asyncio +import sys import warnings from dataclasses import dataclass from typing import Any from typing import Callable -from typing import ParamSpec from typing import TypeVar +if sys.version_info < (3, 10): + from typing_extensions import ParamSpec +else: + from typing import ParamSpec + from .directives import Include @@ -17,6 +22,10 @@ class _ExtensionEntry: method: Callable[..., Any] +T = TypeVar('T') +P = ParamSpec('P') + + @dataclass class _ExtensionMethodRegistry: sync_methods: dict[str, _ExtensionEntry] @@ -65,10 +74,6 @@ def merge(self, other: _ExtensionMethodRegistry) -> None: _extension_method_registry = _ExtensionMethodRegistry(sync_methods={}, async_methods={}) -T = TypeVar('T') -P = ParamSpec('P') - - class Extension: def __init__( self,