Re: Any way to "subclass" typing.Annotated?

Liste des GroupesRevenir à cl python 
Sujet : Re: Any way to "subclass" typing.Annotated?
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 29. Jan 2025, 14:48:00
Autres entêtes
Organisation : Stefan Ram
Message-ID : <Any-20250129144747@ram.dialup.fu-berlin.de>
References : 1 2
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
Option 2: Custom Wrapper Class

  To compile, this should read:

  Python

from typing import Annotated, TypeVar, Generic, Any

# Your trusty "abstract" flag, chillin' like it's at Venice Beach
abstract = object()

# Type variable, as constant as the NorCal fog
T = TypeVar("T")

class AbstractClassVariable(Generic[T]):
    def __class_getitem__(cls, item: T) -> Any:
        return Annotated[item, abstract]



Date Sujet#  Auteur
28 Jan 25 * Any way to "subclass" typing.Annotated?5Ian Pilcher
29 Jan 25 `* Re: Any way to "subclass" typing.Annotated?4Stefan Ram
29 Jan 25  +- Re: Any way to "subclass" typing.Annotated?1Stefan Ram
29 Jan 25  +- Re: Any way to "subclass" typing.Annotated?1Stefan Ram
29 Jan 25  `- Re: Any way to "subclass" typing.Annotated?1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal