Files
openide/python/testData/paramInfo/DataclassTransformConstructorSignatureWithFieldsAnnotatedWithGenericDescriptor.py
Daniil Kalinin c653a43cab PY-76149 Support descriptor types as annotations for dataclass fields
(cherry picked from commit 78a127e1a0083ece810ad996124ad6ea65887da2)

GitOrigin-RevId: 0c33fe51f5f13116f773577056317c537cbc83ef
2024-10-28 20:14:19 +00:00

20 lines
359 B
Python

from typing import dataclass_transform, TypeVar, Generic
T = TypeVar("T")
@dataclass_transform()
def deco(cls):
...
class MyDescriptor(Generic[T]):
def __set__(self, obj: object, value: T) -> None:
...
@deco
class MyClass:
id: MyDescriptor[int]
name: MyDescriptor[str]
year: MyDescriptor[int]
new: MyDescriptor[bool]
MyClass(<arg1>)