From b1e7325e27fcc6bc33907cc5803fd79cc7faf9ab Mon Sep 17 00:00:00 2001 From: bswck Date: Wed, 7 Feb 2024 18:23:41 +0100 Subject: [PATCH] Use `Protocol[_T]` as `_ClassPropertyAttribute` base --- jaraco/classes/properties.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jaraco/classes/properties.py b/jaraco/classes/properties.py index 87d11a3..c0c49be 100644 --- a/jaraco/classes/properties.py +++ b/jaraco/classes/properties.py @@ -3,12 +3,10 @@ from typing import TYPE_CHECKING, Generic, TypeVar, cast, overload _T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_T_contra = TypeVar("_T_contra", contravariant=True) if TYPE_CHECKING: from collections.abc import Callable - from typing import Any + from typing import Any, Protocol from typing_extensions import Self, TypeAlias @@ -20,7 +18,7 @@ _SetterCallable: TypeAlias = Callable[[type[Any], _T], None] _SetterClassMethod: TypeAlias = classmethod[Any, [_T], None] - class _ClassPropertyAttribute(Generic[_T]): + class _ClassPropertyAttribute(Protocol[_T]): def __get__(self, obj: object, objtype: type[Any] | None = None) -> _T: ... def __set__(self, obj: object, value: _T) -> None: ...