Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Joy is wealth and love is the legal tender of the soul." -- Robert G. Ingersoll


devel / comp.lang.python / Re: Forward References

SubjectAuthor
o Re: Forward ReferencesMRAB

1
Re: Forward References

<mailman.277.1693781987.23016.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23958&group=comp.lang.python#23958

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: Forward References
Date: Sun, 3 Sep 2023 23:56:37 +0100
Lines: 31
Message-ID: <mailman.277.1693781987.23016.python-list@python.org>
References: <CAApdmf2oFnjcTa86k3y+SXx-WCkSxXbFd2nyFJs6XyHUOzHLgQ@mail.gmail.com>
<21022483-f694-1080-9ecc-11826514468d@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de q2TfHJNFdAR6j1JjX8bkjwVYBGjKSot/sLZbfoQ9LCWw==
Cancel-Lock: sha1:9nEKEeN6OUzO2E/BuzbzBxWDE54= sha256:dLjhhoaxDFZiSxPatfJlEig9BM+CKw41VimL3YNAoq8=
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=F/EfnsJM;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.014
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'string': 0.07;
'from:addr:python': 0.09; 'int': 0.09; 'received:192.168.1.64':
0.09; 'skip:@ 20': 0.09; 'import': 0.15; '__future__': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'message-id:@mrabarnett.plus.com': 0.16; 'order?': 0.16;
'received:plus.net': 0.16; 'typing': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'i.e.': 0.22; 'anyone': 0.25;
'suggest': 0.28; 'header:User-Agent:1': 0.30; 'putting': 0.31;
'program': 0.31; "doesn't": 0.32; 'python-list': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; 'header:In-Reply-To:1':
0.34; 'usual': 0.35; 'fix': 0.36; 'class': 0.37;
'received:192.168': 0.37; 'way': 0.38; 'use': 0.39; 'should':
0.40; 'sample': 0.61; 'forward': 0.62; 'received:212': 0.62;
'here': 0.62; 'pass': 0.64; 'older': 0.70; 'deal': 0.73; 'union':
0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1693781799; bh=JZ8StrswsdpJi6oMfewBGGl2RfFq3v9oHtoX6SDYXIU=;
h=Date:Subject:To:References:From:In-Reply-To;
b=F/EfnsJMe7m5JeSI9A8vGgLSQtT5d8woKkCtsOSioihfswltcpVfaY5PsCuT9K1rP
mtMkTcmLHluV5diqHhpPnVAS6LjYm9PMBKELI096pGoHlmq1+ZRdRxy05VkJwKm+VG
buaWJb1H9IZ7rDcwjzDMZDpuDy1HgIFW2DZaBaPOvSnlPpDaG/Z18wMVgP8RYWIpBp
GrauHw3dfkXIS/Kgvtv07xyaRK/tk67UtJcE/eUr4zWI7X3+X9jfYgBTJf0NmhFV6g
r7KNUoTyWYwmsnHZB0HYGn+HJ+AxW20SfORv8cDuAfFuuh/LVz1bBHwLYWl5sr/0u5
CxZxsXsZjYcpQ==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=PvSA0iA3 c=1 sm=1 tr=0 ts=64f50f27
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=3fb-qkFEQPjS1FskGcoA:9 a=QEXdDO2ut3YA:10
a=ZXulRonScM0A:10 a=zZCYzV9kfG8A:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
Content-Language: en-GB
In-Reply-To: <CAApdmf2oFnjcTa86k3y+SXx-WCkSxXbFd2nyFJs6XyHUOzHLgQ@mail.gmail.com>
X-CMAE-Envelope: MS4xfL1e+rtn+5Nba1zglh05ddwVB6JyH8/mXoH2YTBNaN4rr4CvtycDtixSWhhlnZonPkq4tYFVZ0lIZw/PDeOKH0zeCa5Kbt7UmEl7MTpzt5vQCgo1NJ/R
606td/bPYC5GJnPIN4A+LmHdBgr6isJypqavI3hyNdy4YQyeMg90t+RsQBdNoEOH7BpcFLwlNrXBIuMB5ZBnMu4UwLDo5DEL0WE=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <21022483-f694-1080-9ecc-11826514468d@mrabarnett.plus.com>
X-Mailman-Original-References: <CAApdmf2oFnjcTa86k3y+SXx-WCkSxXbFd2nyFJs6XyHUOzHLgQ@mail.gmail.com>
 by: MRAB - Sun, 3 Sep 2023 22:56 UTC

On 2023-09-03 21:43, Jonathan Gossage via Python-list wrote:
> I am attempting to use forward references in my program and I am failing.
> This also does not work with the older way of putting the name of a class
> as a string. Here is some sample code:
>
> from __future__ import annotations
>
> from dataclasses import dataclass
> from typing import TypeAlias
>
>
> ColorDef: TypeAlias = RGB | int | str
>
>
>
> @dataclass(frozen=True, slots=True)
> class RGB(object):
>
> Can anyone suggest how I should fix this without reversing the statement
> order?
>
> pass
>
The usual way to deal with forward type references is to use a string
literal, i.e. 'RGB', but that doesn't work with '|', so use typing.Union
instead:

from typing import TypeAlias, Union

ColorDef: TypeAlias = Union['RGB', int, str]

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor