From 82a7a980c9daac52501c55c3ccaf6b3b6f4a6677 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 20 Nov 2021 11:35:28 +0300 Subject: [PATCH 1/2] Do not use `ClassVar`s with generic variables --- stdlib/@python2/ctypes/__init__.pyi | 4 ++-- stdlib/ctypes/__init__.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 149e9f281647..ae17b2b20c5d 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -166,7 +166,7 @@ def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ... # ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer, # it can be instantiated directly (to mimic the behavior of the real pointer function). class pointer(Generic[_CT], _PointerLike, _CData): - _type_: ClassVar[Type[_CT]] = ... + _type_: Type[_CT] = ... contents: _CT = ... def __init__(self, arg: _CT = ...) -> None: ... @overload @@ -263,7 +263,7 @@ class LittleEndianStructure(Structure): ... class Array(Generic[_CT], _CData): _length_: ClassVar[int] = ... - _type_: ClassVar[Type[_CT]] = ... + _type_: ClassVar[type] = ... raw: bytes = ... # Note: only available if _CT == c_char value: Any = ... # Note: bytes if _CT == c_char, Text if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment. diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 4b3dd4b15b51..b9fac170974b 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -173,7 +173,7 @@ def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ... # ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer, # it can be instantiated directly (to mimic the behavior of the real pointer function). class pointer(Generic[_CT], _PointerLike, _CData): - _type_: ClassVar[Type[_CT]] + _type_: Type[_CT] contents: _CT def __init__(self, arg: _CT = ...) -> None: ... @overload @@ -269,7 +269,7 @@ class LittleEndianStructure(Structure): ... class Array(Generic[_CT], _CData): _length_: ClassVar[int] - _type_: ClassVar[Type[_CT]] + _type_: ClassVar[type] raw: bytes # Note: only available if _CT == c_char value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment. From 2e3344df8045b38b200a31c42d1897c77ae42981 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 20 Nov 2021 11:44:45 +0300 Subject: [PATCH 2/2] Do not use `ClassVar`s with generic variables --- stdlib/@python2/ctypes/__init__.pyi | 4 ++-- stdlib/ctypes/__init__.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index ae17b2b20c5d..33184cc2ff88 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -262,8 +262,8 @@ class BigEndianStructure(Structure): ... class LittleEndianStructure(Structure): ... class Array(Generic[_CT], _CData): - _length_: ClassVar[int] = ... - _type_: ClassVar[type] = ... + _length_: int = ... + _type_: Type[_CT] = ... raw: bytes = ... # Note: only available if _CT == c_char value: Any = ... # Note: bytes if _CT == c_char, Text if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment. diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index b9fac170974b..bbe083f5d4c4 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -268,8 +268,8 @@ class BigEndianStructure(Structure): ... class LittleEndianStructure(Structure): ... class Array(Generic[_CT], _CData): - _length_: ClassVar[int] - _type_: ClassVar[type] + _length_: int + _type_: Type[_CT] raw: bytes # Note: only available if _CT == c_char value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment.