Path: ...!news.mixmin.net!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: comp.lang.python Subject: Re: Any way to "subclass" typing.Annotated? Date: 29 Jan 2025 13:48:00 GMT Organization: Stefan Ram Lines: 20 Expires: 1 Jan 2026 11:59:58 GMT Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 0Lb6YAZfmG3R20SFwwuZbQwHfA0u/cpX3uKdFLG4Nf4qMj Cancel-Lock: sha1:XWCUT9rLKtXY+0zb2HGm/RkeNHw= sha256:f8G4ORJQh2duTATpW7hWXE51BNuk1o26AqpQ1igXSyI= X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: en-US Bytes: 1925 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]